Real-time line chart time x-axis

OK - so here is my issue. I am using a chart on a dashboard to display real-time data. I have 4 data sources, each of which are sampled at slightly different times and so I pass the data directly from each source to the chart as a separate payload as and when data arrives. I use a very simple function to create the payload to send to the chart (as below). The data displays fine. However, there are 2 issues:

  1. Controlling the chart colours - the colours are assigned by data arrival time. So when the system is restarted, if sensor 2 arrives first it will get the Series1 colour. But sometimes it may be another sensor that samples first. How do I tell the chart which colour to use for that data?

  2. Changing the x-axis - I am not sending x-axis data, rather the chart is using the timestamp automatically. This is fine as it is a time-series chart. However, using the filter on the chart to say "last 3 hours" makes no difference.

Here is the payload I send (sorry can't send whole JSON of flow due to complexity and privacy of customer solution).

var a = msg.payload;
var msg1 = {
    "topic": a.sensorID,
    "payload": a.sensorValue
};
return msg1;

for

  1. use a ui_control node to detect when a browser connects... use that to trigger a send of an array of empty data points but with the correct topics set - in the order you wish - so they always allocate the colours correctly.

  2. not sure what you mean ? the chart won't update unless new data arrives so if nothing arrives for 4 hours the data shown will be 4 hours old. If you need to force last 3 hours then you will need to send (or resend) data to fill in the gaps. Or did you mean you want to change the width of the x axis dynamically ? Again this can be done by using ui_control message into the node - https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md

thanks for #1 !

for #2, if I leave the data to run the graph shows a the length of time the solution has run as opposed to what is selected in the Chart settings (e.g. show last 3 hours only)

Perhaps you are confused by the operation before there are three hours worth of data. It will show all the data there is along the x axis, but when it gets to three hours then it will stick at that, dropping old data off as new arrives.

and therein is the problem :wink: it doesn't do that, it keeps all the old data so just grows and grows

Show us a screenshot and the config of the node.
Also post the startup log when you start node red in a terminal.

Should I deduce that you have solved the problem?

sorry - been off ill for a few days! Can't accecss the startup log as it is on an appliance where Node-Red is embedded as a service and I don't have access to the logs. Here is a screenshot of the node though:

Well that makes life rather difficult. What appliance is it?
What version of node-red and node-red-dashboard is it running? Also what version of nodejs? Assuming you have access to a terminal then node -v will tell you that.

[Edit] Also a screenshot of the chart mis-behaving please.