Hello @Andrei,
Could you indulge for one+ iteration yet again? I need to display (retrieved in the sense that I have control over the rows and columns) data in a multi-line chart. I have read some of the discussions and you were kind enough to assist me with tabulating similar data with Angular expressions. In the current situation, it is my understanding that JSONata can do the trick but after several attempts I feel that the expertise needed to solve the problem is significantly above my pay grade.
The data is as follows:
[
[
{
"RID": 1,
"Waqt": "2020-03-09T17:56:18.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 2,
"Waqt": "2020-03-09T22:57:00.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.43,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 5,
"Waqt": "2020-03-09T17:57:18.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 6,
"Waqt": "2020-03-09T22:58:00.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.5,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 9,
"Waqt": "2020-03-09T17:58:18.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 10,
"Waqt": "2020-03-09T22:59:01.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.37,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 13,
"Waqt": "2020-03-09T17:59:18.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 14,
"Waqt": "2020-03-09T23:00:01.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.5,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 17,
"Waqt": "2020-03-09T18:00:18.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 18,
"Waqt": "2020-03-09T23:01:01.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.43,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 21,
"Waqt": "2020-03-09T18:01:17.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 22,
"Waqt": "2020-03-09T23:02:01.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.35,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 25,
"Waqt": "2020-03-09T18:02:17.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 26,
"Waqt": "2020-03-09T23:03:02.000Z",
"DeviceId": 1453,
"Status": "2",
"Reading": 34.41,
"Dimension": "Temperature",
"UOM": "°C"
},
{
"RID": 29,
"Waqt": "2020-03-09T18:03:17.000Z",
"DeviceId": 1461,
"Status": "0",
"Reading": 100,
"Dimension": "Temperature",
"UOM": "°C"
},
],
{
"fieldCount": 0,
"affectedRows": 0,
"insertId": 0,
"serverStatus": 34,
"warningCount": 0,
"message": "",
"protocol41": true,
"changedRows": 0
}
]
It is my understanding that this data has to be cast "somehow." While I was able to use simple JSONata, I got lost completely in deeper expressions with the JSONata Exerciser. My last attempt was as follows:
(
$series := [
{ "field": $distinct($.Dimension), "label": $distinct($.DeviceId) }
];
$xaxis := $.Waqt;
$yaxis := $.field;
{
"series": $series.label,
"data": $series.
(
$yaxis := $.Reading;
$$.payload.{
"x": $lookup($, $xaxis),
"y": $lookup($, $yaxis)
}
)
}
)
DeviceId, Waqt & Reading are in the input data stream. I need help in assembling them for multiline chart usage. Of course, the JSONata expression above is completely erroneous but I don't know how to recover. Any advice would be appreciated. You can recommend changes (to input also) as you see fit. Thanks.
Kind regards.