# Please show me how to get a simple bar chart from simple data

**URL:** <https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292>\
**Category:** Dashboard\
**Created:** [8 January 2022 11:10 UTC](https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292 "2022-01-08T11:10:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 January 2022 11:10 UTC](https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292/1 "2022-01-08T11:10:22Z")

</div>

I haven't used a dashboard in years but just wanted a simple bar chart of some cheerlight tweets I've been collecting but I'm stumped as to how to get there

This is example of my data

```auto
{"ArmyOfThings":17,"DiscCheerlights":4,"EchoCheerlights":3,"CympleRobot":7,"cymplecy":1}

```

How do I convert it into something that the chart dashboard node understands to produce a simple bar chart of the values with the appropriate labels

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 January 2022 12:00 UTC](https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292/2 "2022-01-08T12:00:24Z")

</div>

Try this JSONata expression

```auto
[{"id":"c9893796.08e33","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ArmyOfThings\":17,\"DiscCheerlights\":4,\"EchoCheerlights\":3,\"CympleRobot\":7,\"cymplecy\":1}","payloadType":"json","x":120,"y":1220,"wires":[["4adc95cf.27063c"]]},{"id":"4adc95cf.27063c","type":"change","z":"c791cbc0.84f648","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"($labels := [$keys($$.payload)];\t[{\t \"series\": [],\t \"data\": [[$labels.$lookup($$.payload, $)]] ,\t \"labels\": [$labels.$substring(0,10)]\t}]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1180,"wires":[["1dcd707332701bf2","5f2157d0.903098"]]},{"id":"5f2157d0.903098","type":"ui_chart","z":"c791cbc0.84f648","name":"","group":"8b5cde76.edd58","order":9,"width":0,"height":0,"label":"chart","chartType":"bar","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"5","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":690,"y":1040,"wires":[[]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"default","tab":"8f03e639.85956","order":1,"disp":false,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

expression

```auto
(
   $labels := [$keys($$.payload)];
   [
       {
           "series": [],
           "data": [[$labels.$lookup($$.payload, $)]] ,
           "labels": [$labels.$substring(0,10)]
        }
   ]
)

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [8 January 2022 12:10 UTC](https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292/3 "2022-01-08T12:10:26Z")

</div>

Lovely thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 January 2022 12:11 UTC](https://discourse.nodered.org/t/please-show-me-how-to-get-a-simple-bar-chart-from-simple-data/56292/4 "2022-01-22T12:11:05Z")

</div>

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