Multiple line chart instructions

Hello,
I am new to node red and I have problems creating simple multiple line chart. I red many examples and watch a lot of videos and I still dont know what I am doing wrong. I came so far that I am getting data to chart but only as a point. There is no real time x axis.

My code:

var l1 = msg.payload.L1; //get payload
var l2 = msg.payload.L2;
var l3 = msg.payload.L3;

var Napetost1 = [{
   "series": ["L1"],
    "data": [l1],
    "labels": [""],
}];
var Napetost2 = [{
    "series": ["L2"],
    "data": [l2],
    "labels": [""],
}];
var Napetost2 = [{
    "series": ["L3"],
    "data": [l3],
    "labels": [""],
}];
msg.payload = [{
    "series": ["L1", "L2", "L3"], 
    "data": [[l1], [l2], [l3]], 
    "labels": [""] }]
return msg;

Please if any one can tell me what I missed in all instructions I read.

br
Aleksander

Is this a live chart or historical data?
What is the contents of msg.payload?

...It is a live chart. Data is from S7 node.

Is there a reason you only answered one question?

... sorry, but I am not sure what you mean. I collect data from siemens PLC and I am trying to show them in chart. Data from PLC are

I mean the payload going into the function node as above.

... so payload datas are variables of type "Real", I get them from S7 PLC. ?

If you do not give the contents of msg.payload I can not help.

... I realy dont understant what you need, can you show me example, or tell me what to copy?

I require the contents of msg.payload, stick a debug on the s7 node and copy the contents using the copy value button,. Read here for more info on copying values

Please help us help you by reading the documentation and getting a basic understanding of how node-red works.

...
image

Help us help you and provide what i asked for in the format i ask. I need you to use the copy value icon, read what i asked you to read, and provide the data as text.

...following payload from function to chart
[{"series":["L1","L2","L3"],"data":[225,235,229],"labels":[""]}]
...folowing payload from s7 to function
{"I1":1,"I2":2,"I3":3,"L1":225,"L2":235,"L3":232}

example with your incoming payload.

[{"id":"79e0b5a157701d91","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"I1\":1,\"I2\":2,\"I3\":3,\"L1\":225,\"L2\":235,\"L3\":232}","payloadType":"json","x":110,"y":540,"wires":[["92ce61da44348d5e"]]},{"id":"92ce61da44348d5e","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"delete","p":"payload.I1","pt":"msg"},{"t":"delete","p":"payload.I2","pt":"msg"},{"t":"delete","p":"payload.I3","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":580,"wires":[["d4e7fd40495eac8b"]]},{"id":"d4e7fd40495eac8b","type":"split","z":"65617ffeb779f51c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":450,"y":580,"wires":[["c1b0021ca796317f"]]},{"id":"c1b0021ca796317f","type":"debug","z":"65617ffeb779f51c","name":"chart","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":596,"y":688,"wires":[]}]

How to import a flow

1 Like

... sorry but can you explain what did you sent and where I should copy this?

See link provided.

Again please read the documentation and watch the videos, it will make using node-red and asking for help much easier.

...like I said I am a beginer in node red. I read I lot about it but one is theory and other is practical usage. I manage to import your flow. Thank you. I will test it.
Thank you again.

... tested. Working!

Thank you again.

As a 'Beginner' it would be well worth you watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

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