# Chart dashboard and variable axises

**URL:** <https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135>\
**Category:** Dashboard\
**Created:** [7 July 2021 12:25 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135 "2021-07-07T12:25:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mari](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@mari](https://discourse.nodered.org/u/mari)\
**Post date:** [7 July 2021 12:25 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/1 "2021-07-07T12:25:48Z")

</div>

hi all,  
I have access to a sensor data containing (time (UTC), battery voltage, temperature, ..) in InfluxDB using NodeRed like the image

 ![WhatsApp Image 2021-07-07 at 14.19.03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b4e1e4be095fef9a3d0da50b30ee3ce7fd48a279.jpeg)

**(every 4 mins, new data is added to influxDB)**  
, and I want to use chart dashboard in NodeRed to show temperature data based on time. I am very new to NodeRed. Y and X axises data are dynamic in my case, but the examples I saw on the internet are for stored data with fix amount. for example:

```auto
[{
"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": [""]
}]

```

I would appreciate it if someone could advise me how I can use chart dashboard with variable stored data.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 July 2021 12:28 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/2 "2021-07-07T12:28:18Z")

</div>

Search the forum there is many dynamic examples.

However... you might have a problem with those values - they seem to be all strings with the unit attached to the end. You should really only store the actual value in the database. The unit of measure is really only for when you present the values to a front end or user.

---

<div class="post-metadata">

**Author:** ![mari](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@mari](https://discourse.nodered.org/u/mari)\
**Post date:** [7 July 2021 12:51 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/3 "2021-07-07T12:51:58Z")

</div>

@Steve-Mcl  
thank you very much for your quick reply and advice,  
yes, I should write a function which removes the unit and return time and temperature data only, and my problem is regarding finding related example in the forum considering I think I should consider both (X-Y) variable dynamic, but could not find a related example  
I would greatly appreciate it if someone could propose me related topics or advise me in this regard  
**(every 4 mins, new data is added to influxDB)**

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 July 2021 15:06 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/4 "2021-07-07T15:06:50Z")

</div>

You need to change the way you write the data to influx. Make sure all the values are numbers not strings. You will need, in influx, to drop the Influxdb Measurement where the data are stored as it is not possible to change the field type once the field has been created.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 July 2021 15:14 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/5 "2021-07-07T15:14:56Z")

</div>

Here is a flow to draw temperature and humidity charts from a database (I use mysql). I'm sure it is copied from another forum thread.

```auto
[{"id":"91271c26.3a1e4","type":"inject","z":"80222fae.fe94c","name":"Define SQL","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"select * from mytable","payload":"","payloadType":"date","x":150,"y":80,"wires":[["dddef08a.ed0728"]]},{"id":"dddef08a.ed0728","type":"mysql","z":"80222fae.fe94c","mydb":"e92693f3.b0bc68","name":"db","x":310,"y":80,"wires":[["3ad73d6c.b2d132"]]},{"id":"3ad73d6c.b2d132","type":"function","z":"80222fae.fe94c","name":"Format","func":"let labels = [];\nlet data = [];\nlet data1 = [];\nlet msg1 = {};\n\nmsg.payload.forEach(myFunction);\n\nfunction myFunction(item, index) { \n data.push(item.temperature);\n labels.push(item.timestamp);\n data1.push(item.humidity);\n}\n\nmsg.payload = [{\n \"series\": [\"Temperature\"],\n \"data\": [data],\n \"labels\": labels \n}];\n\nmsg1.payload = [{\n \"series\": [\"Humidity\"],\n \"data\": [data1],\n \"labels\": labels \n}];\n\nreturn [msg, msg1];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":80,"wires":[["92bac926.09f5"],["229af107.7b51d6"]]},{"id":"92bac926.09f5","type":"ui_chart","z":"80222fae.fe94c","name":"","group":"a6e358b.672ffa8","order":13,"width":"7","height":"4","label":"temp (°C)","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":620,"y":60,"wires":[[]]},{"id":"229af107.7b51d6","type":"ui_chart","z":"80222fae.fe94c","name":"","group":"a6e358b.672ffa8","order":13,"width":"7","height":"4","label":"humidity (%)","chartType":"line","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":630,"y":100,"wires":[[]]},{"id":"e92693f3.b0bc68","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"test","tz":"","charset":"UTF8"},{"id":"a6e358b.672ffa8","type":"ui_group","name":"Demo","tab":"4e528085.a1bfa","order":1,"disp":true,"width":"20","collapse":false},{"id":"4e528085.a1bfa","type":"ui_tab","name":"Demo","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9229eb70f429f02e617b48e5b119cbe41c4dd5d.jpeg)

---

<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:** [6 August 2021 15:15 UTC](https://discourse.nodered.org/t/chart-dashboard-and-variable-axises/48135/6 "2021-08-06T15:15:44Z")

</div>

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