Extracting json fields from encoded json string under datasets property - Custom Charts

Hey guys,

My question veers more into the use of vega-5 / vega-lite rather than Losant but I haven’t found a great answer thus far so hoping someone here is able to help. I apologise if the solution is straightforward, I have had a bit of trouble getting accustomed to the use of the vega syntax in Losant…

I am trying to adapt a radar plot for a simplified windrose and have my input data in the form of encoded json strings. I have a gauge query which gets the last value of this attribute.

image

This json string is of the form…
{
“name” : “windRose”,
“values”:
[
{ “key”: “some_key”, “value”: some_value, “category”: some_category},

{ “key”: “some_key”, “value”: some_value, “category”: some_category},
]
}

If the query name is windData is there an easy way to parse the object found under the datasets property to extract the name and list of values? Is a reference to windData in the data properties still required? If this is not easily done, is there a convenient way to do this using .json files stored as blobs on the device state?

Also curious if there is a way to simply display what is stored under the datasets property as a sanity check.

Thanks for any and all help,
Andre

Hi @MaskiMan21 and welcome to the Losant forums!

In the Custom Chart block, currently, you can view the raw data being returned from a query by looking at your browser’s Network tab under the Response object:

However, in our next release (scheduled for June 13th), we will start exposing this data in the Custom Chart block editor UI. More info to come on that soon.

Hopefully this will point you in the right direction on how the data should be referenced in your Vega spec. If you have any further questions, please let us know!