6. Adding Data to Chart Node

Next, we will populate the chart with data from two different motors. Similar to our example in adding data to our gauge nodes, we will insert an inject node and a function node and connect them to each other.

Double-click on the function node and copy the following code

var msg = {};
var msg1 = {};
msg.payload = Math.round(Math.random()*1000)+500;
msg.topic = 'Motor 1 RPM';
msg1.payload = (Math.round(Math.random()*1000)+1000)*2;
msg1.topic = 'Motor 2 RPM';
return [msg, msg1];

and change the name to 2 Motors RPMS , and the output to two. This will allow you to output two different outputs into your chart node.

Click Done once the function is complete.

We will use the inject node to trigger this function every 3 seconds. To do this, double-click on each inject node and change the following parameters.

Click Done after parameters are set.

Ensure that both outputs of the function node are connected to the chart node.