I have a NodeRED dashboard which is a regular line chart. Now the chart get's all the data and graph the 2 lines as I would expect but I tried to replace the x-axis(default output : time) with real time 'footage'. Not sure what I do wrong here but I'm getting some wrong outputs for the x-axis. Note : I have calculated the anticipated x-axis(footage) and outputting it with "node.warn()" and I'm seeing the correct numbers there.
My code :
let topic = msg.topic;
var leftArrayPoint = msg.payload.readResults[2].v;
var rightArrayPoint = msg.payload.readResults[3].v;
var xnew = ((((leftArrayPoint+rightArrayPoint)/2)*0.49)*4.54)/12;
var left = {topic:"camberIN", "x":xnew, payload : msg.payload.readResults[0].v };
var min = {topic:"min", "x":xnew, payload : 0.005 };
var right = {topic:"camberOUT", "x":xnew, payload : msg.payload.readResults[1].v };
var max = {topic:"max", "x":xnew, payload : 0.04 };
node.warn(leftArrayPoint);
node.warn(rightArrayPoint);
node.warn(xnew);
return [[left,right,min,max]];
This is my whole node :
[{"id":"46575e61.69efb","type":"http request","z":"d9ca844b.3088d8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://10.0.12.32:39320/iotgateway/read?ids=AB.CMM.Prgm_MainProgram.f_ten_point_avg_left_camber&ids=AB.CMM.Prgm_MainProgram.f_ten_point_avg_right_camber&ids=AB.CMM.Prgm_MainProgram.f_left_array_position&ids=AB.CMM.Prgm_MainProgram.f_right_array_position","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":180,"wires":[["911ed340.7b266"]]},{"id":"cce5ad8e.ac6ff","type":"inject","z":"d9ca844b.3088d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"camberIN","payload":"","payloadType":"date","x":150,"y":160,"wires":[["46575e61.69efb"]]},{"id":"911ed340.7b266","type":"function","z":"d9ca844b.3088d8","name":"graph","func":"let topic = msg.topic;\n\n var leftArrayPoint = msg.payload.readResults[2].v;\n var rightArrayPoint = msg.payload.readResults[3].v;\n \n var xnew = ((((leftArrayPoint+rightArrayPoint)/2)*0.49)*4.54)/12;\n\n\n var left = {topic:\"camberIN\", \"x\":xnew, payload : msg.payload.readResults[0].v };\n var min = {topic:\"min\", \"x\":xnew, payload : 0.005 };\n\n var right = {topic:\"camberOUT\", \"x\":xnew, payload : msg.payload.readResults[1].v };\n var max = {topic:\"max\", \"x\":xnew, payload : 0.04 };\n \n node.warn(leftArrayPoint);\n node.warn(rightArrayPoint);\n node.warn(xnew);\n\nreturn [[left,right,min,max]];\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":650,"y":180,"wires":[["44f64680.766f78"]]},{"id":"55d16c04.e013d4","type":"inject","z":"d9ca844b.3088d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"camberOUT","payload":"","payloadType":"date","x":150,"y":240,"wires":[["46575e61.69efb"]]},{"id":"44f64680.766f78","type":"ui_chart","z":"d9ca844b.3088d8","name":"","group":"2daef4c7.2c9c8c","order":0,"width":"15","height":"15","label":"chart","chartType":"line","legend":"true","xformat":"x","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":850,"y":180,"wires":[[]]},{"id":"203ef2c6.0a0c6e","type":"inject","z":"d9ca844b.3088d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"min","payload":"","payloadType":"date","x":170,"y":100,"wires":[["46575e61.69efb"]]},{"id":"60efcce2.71b384","type":"inject","z":"d9ca844b.3088d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"max","payload":"","payloadType":"date","x":170,"y":300,"wires":[["46575e61.69efb"]]},{"id":"2daef4c7.2c9c8c","type":"ui_group","name":"Camber Measurements","tab":"98adeb9b.8b9978","order":2,"disp":true,"width":"20","collapse":false,"className":""},{"id":"98adeb9b.8b9978","type":"ui_tab","name":"Home","icon":"dashboard"}]