bar chart not showing up on dashboard

392 views
Skip to first unread message

lucy

unread,
Jul 31, 2017, 5:06:18 AM7/31/17
to Node-RED

Hi,
I'm trying to plot a bar chart using node-red dashboard, however I can not find any document explains the input data format. I tried serval data structure as suggest in this forum. Some of them do not work at all, others can only drive line-chart but not bar-chart.

For instance:
[{ key: "storageKey", values: { data:[[1,2,3]], series:["a"], labels:["1", "2", "3"] }}];

var chart =[ { "key": "Last 7 Days", "values": [ [1,25], [2,30], [3,16], [4,20], [5,23], [6,40], [7,10] ] } ];

What exactly is the input format for bar chart? Would someone kindly enlighten me please?

Ps, I would be also grateful if someone can tell me how to change x-axis label as index id ("1", "2", ...)?

greetings

Mark Setrem

unread,
Jul 31, 2017, 6:29:35 AM7/31/17
to Node-RED

taken from https://groups.google.com/forum/#!searchin/node-red/bar$20chart%7Csort:relevance/node-red/MbOPcXNJRzI/jpytrUwKAQAJ

here's an example of a working bar-chart with x-axis labels

[
  {
    "key": "MaxTemp",
    "values": {
      "series": [
        "2017-01-24",
        "2017-01-25"
      ],
      "data": [
        [
          24.6,
          30.03
        ]
      ]
    }
  }
]

Zenofmud

unread,
Jul 31, 2017, 7:16:45 AM7/31/17
to node...@googlegroups.com
Mark, 
I’m also trying to understand how to send a series to a bar chart and have a head cold and things don’t make sense. If I have a function node feeding a bar chart and use this:

var msg1 = { topic : 'C', payload :  75 }; 
node.send(msg1); 
var msg2 = { topic : 'D', payload : 100 }; 
return msg2; 

I see two bars, but if I use this:

var msg = [{"key": "MaxTemp",
            "values": {"series": ["2017-01-24", "2017-01-25"],
                       "data"  : [[24.6, 30.03]]
             }
            }]
return msg; 

nothing shows up in the chart. I just can’t seem to wrap my head about how to send multiple series in one go. I need a bar charts for dummies (sigh).


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/30f8feb1-7f65-48f2-ac64-1663a7aa302c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Setrem

unread,
Jul 31, 2017, 7:26:01 AM7/31/17
to Node-RED

try...

 msg.payload = [{"key": "MaxTemp",

Zenofmud

unread,
Jul 31, 2017, 8:47:03 AM7/31/17
to node...@googlegroups.com
Nope, no data shows up on the chart and this is with NR 0.17.5

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Mark Setrem

unread,
Jul 31, 2017, 8:55:28 AM7/31/17
to Node-RED
This works for me

[{"id":"40444f22.d0b2d8","type":"debug","z":"d7717e9.624828","name":"","active":true,"console":"false","complete":"false","x":430,"y":480,"wires":[]},{"id":"29fa07c5.a14348","type":"inject","z":"d7717e9.624828","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120,"y":540,"wires":[["468d7401.6f8bc4"]]},{"id":"63526ff.bea451","type":"ui_chart","z":"d7717e9.624828","name":"","group":"55d87c07.51858c","order":0,"width":0,"height":0,"label":"chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"x":393.5,"y":590,"wires":[[],[]]},{"id":"468d7401.6f8bc4","type":"function","z":"d7717e9.624828","name":"","func":"msg.payload = [{\"key\": \"MaxTemp\",\n \"values\": {\"series\": [\"A\", \"B\"],\n \t \"data\" : [[24.6, 30.03],[5,7]]\n\t\t }\n }]\nreturn msg; \n","outputs":1,"noerr":0,"x":250,"y":540,"wires":[["63526ff.bea451","40444f22.d0b2d8"]]},{"id":"55d87c07.51858c","type":"ui_group","z":"","name":"Default","tab":"2f99c592.b3081a","disp":true,"width":"6"},{"id":"2f99c592.b3081a","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

Zenofmud

unread,
Jul 31, 2017, 9:32:39 AM7/31/17
to node...@googlegroups.com
Hmm, it doesn’t work for me. What platform are you running it on? I’m running it on OS X, node v6.11.0 and Node-RED v0.17.5

> On Jul 31, 2017, at 8:55 AM, Mark Setrem <mse...@gmail.com> wrote:
>
> This works for me
>
> [{"id":"40444f22.d0b2d8","type":"debug","z":"d7717e9.624828","name":"","active":true,"console":"false","complete":"false","x":430,"y":480,"wires":[]},{"id":"29fa07c5.a14348","type":"inject","z":"d7717e9.624828","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120,"y":540,"wires":[["468d7401.6f8bc4"]]},{"id":"63526ff.bea451","type":"ui_chart","z":"d7717e9.624828","name":"","group":"55d87c07.51858c","order":0,"width":0,"height":0,"label":"chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"x":393.5,"y":590,"wires":[[],[]]},{"id":"468d7401.6f8bc4","type":"function","z":"d7717e9.624828","name":"","func":"msg.payload = [{\"key\": \"MaxTemp\",\n \"values\": {\"series\": [\"A\", \"B\"],\n \t \"data\" : [[24.6, 30.03],[5,7]]\n\t\t }\n }]\nreturn msg; \n","outputs":1,"noerr":0,"x":250,"y":540,"wires":[["63526ff.bea451","40444f22.d0b2d8"]]},{"id":"55d87c07.51858c","type":"ui_group","z":"","name":"Default","tab":"2f99c592.b3081a","disp":true,"width":"6"},{"id":"2f99c592.b3081a","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
> To post to this group, send an email to node...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/3497447e-4b38-415a-96bc-8a8171a4f756%40googlegroups.com.

lucy

unread,
Aug 1, 2017, 1:08:54 AM8/1/17
to Node-RED
Thank you for your response. But it doesn't work for me either. I'v try it on both iMac and raspberry pi...

在 2017年7月31日星期一 UTC+8下午8:55:28,Mark Setrem写道:

Mark Setrem

unread,
Aug 2, 2017, 2:33:40 AM8/2/17
to Node-RED
strange! As I'm also on MacOS with the same versions of nodejs and node-red.
There must have been a change introduced in the dashboard node.

Dave C-J

unread,
Aug 2, 2017, 5:42:11 AM8/2/17
to node...@googlegroups.com
for me this is working

[{"id":"9dceb2bd.0dfcb","type":"ui_button","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"A","x":150,"y":160,"wires":[["914ff743.f2e7d8"]]},{"id":"90558645.69e298","type":"ui_button","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":4,"width":"2","height":"1","label":"restore","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":460,"wires":[["5b4b0a04.16bec4"]]},{"id":"914ff743.f2e7d8","type":"random","z":"66461dbc.ceddb4","name":"","low":"0","high":"10","inte":"true","x":300,"y":160,"wires":[["bd250881.402ab8"]]},{"id":"bd250881.402ab8","type":"ui_chart","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":1,"width":0,"height":0,"label":"chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"bezier","nodata":"","dot":false,"ymin":"0","ymax":"10","removeOlder":"15","removeOlderPoints":"100","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":450,"y":160,"wires":[["36721275.1aabce"],[]]},{"id":"16d56f29.aa56e1","type":"file","z":"66461dbc.ceddb4","name":"","filename":"/tmp/chart.log","appendNewline":true,"createDir":false,"overwriteFile":"true","x":600,"y":320,"wires":[]},{"id":"5b4b0a04.16bec4","type":"file in","z":"66461dbc.ceddb4","name":"","filename":"/tmp/chart.log","format":"utf8","x":300,"y":460,"wires":[["cd7861e5.0cd96"]]},{"id":"36721275.1aabce","type":"json","z":"66461dbc.ceddb4","name":"","x":590,"y":160,"wires":[["d901f089.3fd4e"]]},{"id":"cd7861e5.0cd96","type":"json","z":"66461dbc.ceddb4","name":"","x":450,"y":460,"wires":[["bd250881.402ab8"]]},{"id":"d901f089.3fd4e","type":"function","z":"66461dbc.ceddb4","name":"","func":"if (msg.topic === \"save\") {\n    msg.payload = context.last;\n    return msg;\n}\nelse {\n    context.last = msg.payload;\n}\nreturn null;","outputs":1,"noerr":0,"x":330,"y":320,"wires":[["16d56f29.aa56e1"]]},{"id":"c96ae37e.6f4a4","type":"ui_button","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":3,"width":"2","height":"1","label":"save","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"save","x":150,"y":320,"wires":[["d901f089.3fd4e"]]},{"id":"7d95cc5f.a1ee84","type":"ui_button","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"B","x":150,"y":80,"wires":[["85d04893.abd248"]]},{"id":"85d04893.abd248","type":"random","z":"66461dbc.ceddb4","name":"","low":"0","high":"10","inte":"true","x":300,"y":80,"wires":[["bd250881.402ab8"]]},{"id":"2233dc7a.ad8364","type":"ui_button","z":"66461dbc.ceddb4","name":"","group":"5a63086a.527608","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"C","x":150,"y":220,"wires":[["3508afde.8c3fd"]]},{"id":"3508afde.8c3fd","type":"random","z":"66461dbc.ceddb4","name":"","low":"0","high":"10","inte":"true","x":300,"y":220,"wires":[["bd250881.402ab8"]]},{"id":"5a63086a.527608","type":"ui_group","z":"","name":"Gauge","tab":"2effa0c7.cb6e5","order":2,"disp":true,"width":"6"},{"id":"2effa0c7.cb6e5","type":"ui_tab","z":"","name":"Restore","icon":"dashboard"}]

Zenofmud

unread,
Aug 2, 2017, 7:41:46 AM8/2/17
to node...@googlegroups.com
Dave,

Something weird is going on. I import your flow and start up node red and get:
[json:3585b62f.794b62] Ignored unsupported payload type
message in the log and in debug it shows up every time I use the hamburger menu to select the ‘Restore’ page. The debug points at JSON node after the chart node.

In addition, I created a new flow - inject => file node (grabs chart.log) => json node => new bar graph. and point it at a second bar chart. When I press the inject, only one column shows on the chart AND if I refresh the screen, the original chart now shows only one column.

The only way to get multiple columns back is to stop/start node red.

Here is the flow - I changed the location of chart.log since I ran this in OS X

[{"id":"51455089.5c4258","type":"tab","label":"Flow 1"},{"id":"c7bdf931.938f48","type":"ui_button","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"A","x":150,"y":140,"wires":[["43580d6c.61f964"]]},{"id":"4ef5dbcb.e17d74","type":"ui_button","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":4,"width":"2","height":"1","label":"restore","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":440,"wires":[["34973383.43b2c4"]]},{"id":"43580d6c.61f964","type":"random","z":"51455089.5c4258","name":"","low":"0","high":"10","inte":"true","x":300,"y":140,"wires":[["d507582c.e2c728"]]},{"id":"d507582c.e2c728","type":"ui_chart","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":1,"width":0,"height":0,"label":"chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"bezier","nodata":"","dot":false,"ymin":"0","ymax":"10","removeOlder":"15","removeOlderPoints":"100","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":450,"y":140,"wires":[["3585b62f.794b62"],[]]},{"id":"206407cd.682f","type":"file","z":"51455089.5c4258","name":"","filename":"/Users/Paul/tmp/chart.log","appendNewline":true,"createDir":false,"overwriteFile":"true","x":630,"y":260,"wires":[]},{"id":"34973383.43b2c4","type":"file in","z":"51455089.5c4258","name":"","filename":"/Users/Paul/tmp/chart.log","format":"utf8","sendError":true,"x":330,"y":440,"wires":[["c3ae5bbd.0cfbd"]]},{"id":"3585b62f.794b62","type":"json","z":"51455089.5c4258","name":"","x":590,"y":140,"wires":[["38d73ed3.043b32"]]},{"id":"c3ae5bbd.0cfbd","type":"json","z":"51455089.5c4258","name":"","x":570,"y":440,"wires":[["d507582c.e2c728"]]},{"id":"38d73ed3.043b32","type":"function","z":"51455089.5c4258","name":"","func":"if (msg.topic === \"save\") {\n msg.payload = context.last;\n return msg;\n}\nelse {\n context.last = msg.payload;\n}\nreturn null;","outputs":1,"noerr":0,"x":330,"y":300,"wires":[["206407cd.682f"]]},{"id":"d30452ea.6cdce","type":"ui_button","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":3,"width":"2","height":"1","label":"save","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"save","x":150,"y":300,"wires":[["38d73ed3.043b32"]]},{"id":"32a8c59e.abf6a2","type":"ui_button","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"B","x":150,"y":60,"wires":[["ccef0630.30bfa8"]]},{"id":"ccef0630.30bfa8","type":"random","z":"51455089.5c4258","name":"","low":"0","high":"10","inte":"true","x":300,"y":60,"wires":[["d507582c.e2c728"]]},{"id":"c8b30d8e.5d8c2","type":"ui_button","z":"51455089.5c4258","name":"","group":"17da126a.4f866e","order":2,"width":"2","height":"1","passthru":false,"label":"Inject","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"C","x":150,"y":200,"wires":[["f64448e8.5066e8"]]},{"id":"f64448e8.5066e8","type":"random","z":"51455089.5c4258","name":"","low":"0","high":"10","inte":"true","x":300,"y":200,"wires":[["d507582c.e2c728"]]},{"id":"6a7eee02.f8c01","type":"ui_chart","z":"51455089.5c4258","name":"Bar chart 2","group":"17da126a.4f866e","order":5,"width":"0","height":"0","label":"Bar Chart 2","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"chart - test group one","dot":false,"ymin":"0","ymax":"10","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1F77B4","#AEC7E8","#FF7F0E","#2CA02C","#98DF8A","#D62728","#FF9896","#9467BD","#C5B0D5"],"x":730,"y":520,"wires":[[],[]]},{"id":"53bcfbd2.4d097c","type":"file in","z":"51455089.5c4258","name":"","filename":"/Users/Paul/tmp/chart.log","format":"utf8","sendError":true,"x":370,"y":520,"wires":[["e996147e.3a6e08"]]},{"id":"e996147e.3a6e08","type":"json","z":"51455089.5c4258","name":"","pretty":false,"x":570,"y":520,"wires":[["6a7eee02.f8c01"]]},{"id":"8ce6cc2c.ac6a98","type":"inject","z":"51455089.5c4258","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":160,"y":520,"wires":[["53bcfbd2.4d097c"]]},{"id":"17da126a.4f866e","type":"ui_group","z":"","name":"Gauge","tab":"accfb422.f7e54","order":2,"disp":true,"width":"6"},{"id":"accfb422.f7e54","type":"ui_tab","z":"","name":"Restore","icon":"dashboard"}]


Message has been deleted

lucy

unread,
Aug 3, 2017, 4:47:04 AM8/3/17
to Node-RED
same here...

在 2017年8月2日星期三 UTC+8下午7:41:46,Paul Woodard写道:
Reply all
Reply to author
Forward
0 new messages