Chart dashboard and variable axises

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

(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:

[{
"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.

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.

@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)

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.

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.

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

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