Parsing multiple time series data from GraphQL datasource

I’m using Infinity plugin to query graphQL data, pulling multiple series in a response show below.

Trying to figure out how to automatically parse the data for line charts while preserving the individual points names?

Welcome @tsp431

There are a few ways to do it

Check this thread out with use of jsonata

thanks for the reply and linked resource.

I’m still having trouble turning the returned array into a dataset that can be used in timeseries charting

I can use the jsonata parsing to get the array in a single cell in the table, but I think for time series charts I want the ‘timestamp’ entries in a column and the ‘value’ in another column, and the value column header should be the name. Is there some more advanced jsonata parsing that can do this, or do I need to use transformations?


Using the first jsonata then use transformation → extract to unravel that array

ok, getting there

how would I configure the transformation ?

Looks horrible so try this

https://docs.jsonata.org/

do you have any suggestions on what jsonata I can use to return usable arrays?

getting closer, but still having trouble. Let me know if you have any suggestions on how to adjust this query so it is usable

please post the sample data as text not image. cause, you know, not going to type all of that manually :wink:

ah, of course :laughing:

{
  "data": {
    "ahu": {
      "name": "AHU-N",
      "points": [
        {
          "name": "Discharge Air Temperature",
          "unit": "°F",
          "measurements": [
            {
              "timestamp": "2024-02-01T03:00:00-05:00",
              "value": "70.5072021484375"
            },
            {
              "timestamp": "2024-02-01T03:05:00-05:00",
              "value": "70.5072021484375"
            },
            {
              "timestamp": "2024-02-01T03:10:00-05:00",
              "value": "70.5072021484375"
            }
          ]
        },
        {
          "name": "Discharge Air Temperature Setpoint",
          "unit": "°F",
          "measurements": [
            {
              "timestamp": "2024-02-01T03:00:00-05:00",
              "value": "55.0"
            },
            {
              "timestamp": "2024-02-01T03:05:00-05:00",
              "value": "55.0"
            },
            {
              "timestamp": "2024-02-01T03:10:00-05:00",
              "value": "55.0"
            }
          ]
        }
      ]
    }
  }
}

please clean it up

{
"timestamp": "2024-02-01T03:05:00-05:00",
"value": "55.0"
}

not

{
“timestamp”: “2024-02-01T03:05:00-05:00”,
“value”: “55.0”
}

fixed,

apologies

1 Like

how do you want the final data to look like. happy to help as you put some effort to resolve it yourself and are stuck

@yesoreyeram any help on this please, I am stuck with the arrays

somehow with nested jsondata array iterating, you can achieve something like this. ( unfortunately and then two additional transformation to make it work like a timeseries ).

Query

JSONata in root selector

$map(data.ahu.points, function($p){
  $map($p.measurements, function($m){
     return { 
         "name" : $p.name, 
          "t"        : $m.timestamp , 
          "v".     : $number($m.value)
    }
  })
}).*

Transformations

There can be potentially better ways of doing this. but can’t think any of right now.

1 Like

that worked, thank you