Convert object from sqlite to use in line graph

Need help,

I have a Select command from a Sqlite database that gave me the following timestamp and temp values:


I need to be able to be able to convert it to display on a line graph. Any help will be appreciate


Assuming that you are using node-red-dashboard v1...

You need to send your data to the chart node in a specific format:
An array containing a single object with properties "series", "data" and "labels".

  • "series" is an array of the names of lines on the chart. For a single line, just one element in the array.
  • "data" is an array of arrays, one array per line on the chart. Each array element is an object with x and y properties to define the points on the line.
  • "labels" - Actually I'm not sure what labels does, but it is an array of strings, in my experience always an array of one element, an empty string.
"series": ["Series Name"],
"data": [
    [{ "x": 1504029634400, "y": 7 },
     { "x": 1504029637959, "y": 7 },
     { "x": 1504029640317, "y": 7 }
"labels": [""]

You can make the task a bit simpler by tweeking your SQL select statement to return an array of objects with x and y properties - the heart of the "data" array (not tested)
Instead of SELECT timestamp, temp FROM table
SELECT timestamp AS x, temp AS y FROM table


Then feed the SQLite output into a function node to format it for the chart

msg.payload = [{"series":["Temperature"], "data": [msg.payload], "labels":[""]}]
return msg;

The resulting chart

1 Like