Help passing payload to chart

Sorry if this is covered elsewhere but as a newbie I'm looking for some help on how to pass this array data into a chart every 24hours and populates the values into their respective times (using the interval_end as the timestamp).

image

[{"consumption":0,"interval_start":"2022-10-31T23:30:00Z","interval_end":"2022-11-01T00:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T23:00:00Z","interval_end":"2022-10-31T23:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T22:30:00Z","interval_end":"2022-10-31T23:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T22:00:00Z","interval_end":"2022-10-31T22:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T21:30:00Z","interval_end":"2022-10-31T22:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T21:00:00Z","interval_end":"2022-10-31T21:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T20:30:00Z","interval_end":"2022-10-31T21:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T20:00:00Z","interval_end":"2022-10-31T20:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T19:30:00Z","interval_end":"2022-10-31T20:00:00Z"},{"consumption":0.022,"interval_start":"2022-10-31T19:00:00Z","interval_end":"2022-10-31T19:30:00Z"},{"consumption":0.027,"interval_start":"2022-10-31T18:30:00Z","interval_end":"2022-10-31T19:00:00Z"},{"consumption":0.008,"interval_start":"2022-10-31T18:00:00Z","interval_end":"2022-10-31T18:30:00Z"},{"consumption":0.02,"interval_start":"2022-10-31T17:30:00Z","interval_end":"2022-10-31T18:00:00Z"},{"consumption":0.003,"interval_start":"2022-10-31T17:00:00Z","interval_end":"2022-10-31T17:30:00Z"},{"consumption":0.009,"interval_start":"2022-10-31T16:30:00Z","interval_end":"2022-10-31T17:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T16:00:00Z","interval_end":"2022-10-31T16:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T15:30:00Z","interval_end":"2022-10-31T16:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T15:00:00Z","interval_end":"2022-10-31T15:30:00Z"},{"consumption":0.01,"interval_start":"2022-10-31T14:30:00Z","interval_end":"2022-10-31T15:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T14:00:00Z","interval_end":"2022-10-31T14:30:00Z"},{"consumption":0.007,"interval_start":"2022-10-31T13:30:00Z","interval_end":"2022-10-31T14:00:00Z"},{"consumption":0.009,"interval_start":"2022-10-31T13:00:00Z","interval_end":"2022-10-31T13:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T12:30:00Z","interval_end":"2022-10-31T13:00:00Z"},{"consumption":0.007,"interval_start":"2022-10-31T12:00:00Z","interval_end":"2022-10-31T12:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T11:30:00Z","interval_end":"2022-10-31T12:00:00Z"},{"consumption":0.024,"interval_start":"2022-10-31T11:00:00Z","interval_end":"2022-10-31T11:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T10:30:00Z","interval_end":"2022-10-31T11:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T10:00:00Z","interval_end":"2022-10-31T10:30:00Z"},{"consumption":0.042,"interval_start":"2022-10-31T09:30:00Z","interval_end":"2022-10-31T10:00:00Z"},{"consumption":0.025,"interval_start":"2022-10-31T09:00:00Z","interval_end":"2022-10-31T09:30:00Z"},{"consumption":0.01,"interval_start":"2022-10-31T08:30:00Z","interval_end":"2022-10-31T09:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T08:00:00Z","interval_end":"2022-10-31T08:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T07:30:00Z","interval_end":"2022-10-31T08:00:00Z"},{"consumption":0.009,"interval_start":"2022-10-31T07:00:00Z","interval_end":"2022-10-31T07:30:00Z"},{"consumption":0.069,"interval_start":"2022-10-31T06:30:00Z","interval_end":"2022-10-31T07:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T06:00:00Z","interval_end":"2022-10-31T06:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T05:30:00Z","interval_end":"2022-10-31T06:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T05:00:00Z","interval_end":"2022-10-31T05:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T04:30:00Z","interval_end":"2022-10-31T05:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T04:00:00Z","interval_end":"2022-10-31T04:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T03:30:00Z","interval_end":"2022-10-31T04:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T03:00:00Z","interval_end":"2022-10-31T03:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T02:30:00Z","interval_end":"2022-10-31T03:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T02:00:00Z","interval_end":"2022-10-31T02:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T01:30:00Z","interval_end":"2022-10-31T02:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T01:00:00Z","interval_end":"2022-10-31T01:30:00Z"},{"consumption":0,"interval_start":"2022-10-31T00:30:00Z","interval_end":"2022-10-31T01:00:00Z"},{"consumption":0,"interval_start":"2022-10-31T00:00:00Z","interval_end":"2022-10-31T00:30:00Z"}]

Thanks

Example using chamge node and JSONata

[{"id":"9fefbf769eeb8eb3","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"consumption\":0,\"interval_start\":\"2022-10-31T23:30:00Z\",\"interval_end\":\"2022-11-01T00:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T23:00:00Z\",\"interval_end\":\"2022-10-31T23:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T22:30:00Z\",\"interval_end\":\"2022-10-31T23:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T22:00:00Z\",\"interval_end\":\"2022-10-31T22:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T21:30:00Z\",\"interval_end\":\"2022-10-31T22:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T21:00:00Z\",\"interval_end\":\"2022-10-31T21:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T20:30:00Z\",\"interval_end\":\"2022-10-31T21:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T20:00:00Z\",\"interval_end\":\"2022-10-31T20:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T19:30:00Z\",\"interval_end\":\"2022-10-31T20:00:00Z\"},{\"consumption\":0.022,\"interval_start\":\"2022-10-31T19:00:00Z\",\"interval_end\":\"2022-10-31T19:30:00Z\"},{\"consumption\":0.027,\"interval_start\":\"2022-10-31T18:30:00Z\",\"interval_end\":\"2022-10-31T19:00:00Z\"},{\"consumption\":0.008,\"interval_start\":\"2022-10-31T18:00:00Z\",\"interval_end\":\"2022-10-31T18:30:00Z\"},{\"consumption\":0.02,\"interval_start\":\"2022-10-31T17:30:00Z\",\"interval_end\":\"2022-10-31T18:00:00Z\"},{\"consumption\":0.003,\"interval_start\":\"2022-10-31T17:00:00Z\",\"interval_end\":\"2022-10-31T17:30:00Z\"},{\"consumption\":0.009,\"interval_start\":\"2022-10-31T16:30:00Z\",\"interval_end\":\"2022-10-31T17:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T16:00:00Z\",\"interval_end\":\"2022-10-31T16:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T15:30:00Z\",\"interval_end\":\"2022-10-31T16:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T15:00:00Z\",\"interval_end\":\"2022-10-31T15:30:00Z\"},{\"consumption\":0.01,\"interval_start\":\"2022-10-31T14:30:00Z\",\"interval_end\":\"2022-10-31T15:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T14:00:00Z\",\"interval_end\":\"2022-10-31T14:30:00Z\"},{\"consumption\":0.007,\"interval_start\":\"2022-10-31T13:30:00Z\",\"interval_end\":\"2022-10-31T14:00:00Z\"},{\"consumption\":0.009,\"interval_start\":\"2022-10-31T13:00:00Z\",\"interval_end\":\"2022-10-31T13:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T12:30:00Z\",\"interval_end\":\"2022-10-31T13:00:00Z\"},{\"consumption\":0.007,\"interval_start\":\"2022-10-31T12:00:00Z\",\"interval_end\":\"2022-10-31T12:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T11:30:00Z\",\"interval_end\":\"2022-10-31T12:00:00Z\"},{\"consumption\":0.024,\"interval_start\":\"2022-10-31T11:00:00Z\",\"interval_end\":\"2022-10-31T11:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T10:30:00Z\",\"interval_end\":\"2022-10-31T11:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T10:00:00Z\",\"interval_end\":\"2022-10-31T10:30:00Z\"},{\"consumption\":0.042,\"interval_start\":\"2022-10-31T09:30:00Z\",\"interval_end\":\"2022-10-31T10:00:00Z\"},{\"consumption\":0.025,\"interval_start\":\"2022-10-31T09:00:00Z\",\"interval_end\":\"2022-10-31T09:30:00Z\"},{\"consumption\":0.01,\"interval_start\":\"2022-10-31T08:30:00Z\",\"interval_end\":\"2022-10-31T09:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T08:00:00Z\",\"interval_end\":\"2022-10-31T08:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T07:30:00Z\",\"interval_end\":\"2022-10-31T08:00:00Z\"},{\"consumption\":0.009,\"interval_start\":\"2022-10-31T07:00:00Z\",\"interval_end\":\"2022-10-31T07:30:00Z\"},{\"consumption\":0.069,\"interval_start\":\"2022-10-31T06:30:00Z\",\"interval_end\":\"2022-10-31T07:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T06:00:00Z\",\"interval_end\":\"2022-10-31T06:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T05:30:00Z\",\"interval_end\":\"2022-10-31T06:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T05:00:00Z\",\"interval_end\":\"2022-10-31T05:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T04:30:00Z\",\"interval_end\":\"2022-10-31T05:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T04:00:00Z\",\"interval_end\":\"2022-10-31T04:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T03:30:00Z\",\"interval_end\":\"2022-10-31T04:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T03:00:00Z\",\"interval_end\":\"2022-10-31T03:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T02:30:00Z\",\"interval_end\":\"2022-10-31T03:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T02:00:00Z\",\"interval_end\":\"2022-10-31T02:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T01:30:00Z\",\"interval_end\":\"2022-10-31T02:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T01:00:00Z\",\"interval_end\":\"2022-10-31T01:30:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T00:30:00Z\",\"interval_end\":\"2022-10-31T01:00:00Z\"},{\"consumption\":0,\"interval_start\":\"2022-10-31T00:00:00Z\",\"interval_end\":\"2022-10-31T00:30:00Z\"}]","payloadType":"json","x":230,"y":3300,"wires":[["ad5c465f84c94b41"]]},{"id":"ad5c465f84c94b41","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t    {\t        \"series\":[\"consumption\"],\t        \"labels\":[\"your_label\"],\t        \"data\":[[$$.payload.{\"x\": $.interval_end, \"y\": $.consumption}]]\t    }\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":3280,"wires":[["a59660f8257c7f57","e5a2d7fed15fbade"]]},{"id":"a59660f8257c7f57","type":"debug","z":"452103ea51141731","name":"debug 106","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":3240,"wires":[]},{"id":"e5a2d7fed15fbade","type":"ui_chart","z":"452103ea51141731","name":"","group":"2d4fe667.28f8ba","order":17,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":550,"y":3300,"wires":[[]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

formats for chart node-red-dashboard/Charts.md at master · node-red/node-red-dashboard · GitHub

You can use a inject node to initiate the flow every 24 hr.

Thank you so much

How would one go about sending this data to influxdb?

I Think that is a question for its own thread, You will get more responses that way, i do not use influx.

Hi. I am new to Node Red and this forum. So my question which I don't grasp. I want to set the colors of a 3 line chart in the Node Red dashboard to Red, Green and Blue. The code I got is:
msg.ui_control = {"colors":['#FF0000', '#00FF00', '#0000FF', '#000000', '#000000', '#000000', '#000000', '#000000', '#000000']};
I however have no idea where to put this into the chart node, which I assume is where it must go. Hence I double click the node and open it but where does this go or is it part of the file editor?

Please start a new thread in future, as it makes it easier for others to find info. Also make the title descriptive of the issue. You are also less likely to get help posting in a solved thread.

As to your issue, you would feed the property ui_control into the chart node the same time you feed it the payload.
e.g.

[{"id":"a883c08733268c6a","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"ui_control","v":"{\"colors\":[\"#FF0000\",\"#00FF00\",\"#0000FF\"]}","vt":"json"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"series\":[\"A\",\"B\",\"C\"],\"data\":[[{\"x\":1504029632890,\"y\":5},{\"x\":1504029636001,\"y\":4},{\"x\":1504029638656,\"y\":2}],[{\"x\":1504029633514,\"y\":6},{\"x\":1504029636622,\"y\":7},{\"x\":1504029639539,\"y\":6}],[{\"x\":1504029634400,\"y\":7},{\"x\":1504029637959,\"y\":7},{\"x\":1504029640317,\"y\":7}]],\"labels\":[\"\"]}]","payloadType":"json","x":370,"y":1120,"wires":[["ac405c71d633ea19"]]},{"id":"ac405c71d633ea19","type":"ui_chart","z":"452103ea51141731","name":"","group":"2d4fe667.28f8ba","order":16,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"1000","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":650,"y":1040,"wires":[["c58ebb5a56f70f5b"]]},{"id":"c58ebb5a56f70f5b","type":"debug","z":"452103ea51141731","name":"debug 99","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":920,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hi and thank you for getting back to me and I beleve I am busy learning the forum and the Node Red Technology.
I feel a bit lost in two ways.
1 - I went through the menu options of the forum and can't find where to start a new thread, please direct me where to do so,.
2 - I am passing a payload from 3 x numeric nodes to the chart node.
So I got ticked on If new msg arrives on input, pass through to output.
Payload = Current Value
Topic = msg topic
</> Class = Optional CSS class name(s) FOR WIDGET
Name = Blank
Where do I paste ui_control string.

New topic:

you inject or send in the msg.ui_control object along with some data (or maybe dummy blank data)

Thank you for pointing out to me.
I don't know how I missed the New Topic button, as it is very obvious, it could be that I was looking for it while inside one of the topic pages.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.