Drawing a chart in node red dashboard using csv file

I'm trying to display a line chart in the dashboard from a csv file, this chart shows the change of the compressor's power(y-axis) with time(x-axis), i saw some videos showing that i must convert the time to unix format before passing it to the chart, and i did this and saw the output from the debug node and it shows that the date is converted but the chart in the dashboard doesn't seem to work nonetheless, here are the photos for the flow and chart

Almost there, not sure what your code is as image is not really helpful, as hard to read and edit.

data: [data_out],

As data should be an array holding arrays of objects for all series.

1 Like

Thanks that actually worked, but now there's a small issue. the X-axis isnt showing the time correctly, as it's showing time intervals of 15 seconds instead of 15 minutes.
i will leave you the code, a picture of the chart, and a sample of the csv values.

function toTimestamp(strDate){
   var datum = Date.parse(strDate);
   return datum/1000;

var payload=msg.payload;
var Data = "2022-23-6".split("-");
var Data = Data[2]+"/"+Data[1]+"/"+Data[0];
t = toTimestamp(Data + "14:30:00");
var data_out = [];

for(let i=0;i<payload.length;i++)
  var Data= payload[i].Data.split("-")
  var t = Data[2]+"/"+Data[1]+"/"+Data[0];
  var timestamp=toTimestamp(t+" "+payload[i]["Time"]);
  var Power = {"x": timestamp, "y":payload[i]["Compressor (KW)"] };

   "series": ["Compressor (KW)"],
   "labels": ["Compressor (KW)"]
return msg;

Capture 6

Set your timestamps to Javascript timestamps in milliseconds, don't divide them by a 1000.

1 Like

yeah, that did the work, Thanks alot !

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