Hello @Eckehard_Fiedler,
Here are some walkthroughs and examples, let me know if they are unclear in any way!
Replicating Custom Chart Block Data in a Workflow
For your first question, I use the equivalent workflow node for the query I am performing. For example, if I have a Custom Chart block with a Time Series query, like so:
I can replicate how the data will be output by using the Data: Time Series node. I set the values and parameters to be the same as my custom chart block, and am able to see on the payload how my data will be shown.
Upon inspecting my page, you can see that the data from the payload is in the same format:
Your second question has two possible paths. The first route is available if you are trying to show one value. The Vega Lite block is only able to display one query value in its current state. You will also not be able to reference multiple device attribute values, as the configuration syntax will only allow for one “name” value. Likewise, the data available for your selected attribute is limited to time
and value
, the name of the attribute is unaccessible.
The other option you have is to take the Experience route. Here is a great workflow by @anaptfox for working around the single query limit:
Plotting Custom Chart Data with Experience Endpoints
Start by creating a new Experience Endpoint with a Get method:
Next, create an Experience Workflow for your Endpoint. When the Endpoint is triggered, this workflow grabs three of my devices with the Device: Get Node and puts them on the payload. I have “Include the most recent composite state reported” checked on all of these, so that I can easily grab the last value and the time it was reported. This makes it easier to find those “last reported state” values you are looking for.
Here you can see what the Device: Get Node puts on the payload:
Next is a Loop Node containing a Mutate Node and an Array Node. The Mutate Node moves the values we want from compositeState to the current
object and the Array Node creates an array with these values.
We conclude the workflow with the Endpoint Reply, and set the response body to the result.data
payload path.
Now, we can move right along to our Custom Chart block.
This Custom Chart takes no queries, as the data will be accessed via the Endpoint. The code for Vega Lite is as follows:
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {"url": "https://YOUR-APPLICATION-ID.onlosant.com/data?t={{block.time}}"},
"width": {{block.width}},
"height": {{block.height}},
"autosize": {
"type": "fit",
"contains": "padding"
},
"encoding": {
"y": {
"field": "name",
"type": "nominal"
},
"x": {
"field": "temperature",
"type": "quantitative"
},
"color": {
"field": "name",
"type": "nominal",
"scale": {
"range": [
"#EA98D2",
"#659CCA",
"red"
]
}
}
},
"layer": [
{
"mark": "bar"
},
{
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"dx": 3
},
"encoding": {
"text": {
"field": "temperature",
"type": "quantitative"
}
}
}
]
}
This code calls the data with the Endpoint URL, and the {{block.time}}
value allows for the value to b updated each time the dashboard is.
Let me know if you have any questions!
Julia