Two Lines in one chart

Hi,

I want to show two lines in one line chart but it does not work.
The data comes from two databases.

This is my flow trying to make this work:

Blockquote [{"id":"b8f20df9.b9a5c","type":"debug","z":"c4548fd4.bc53e","name":"debug_four","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1300,"y":1150,"wires":},{"id":"ac4fcc0d.a31a3","type":"mysql","z":"c4548fd4.bc53e","mydb":"9ca8d46.70d4c28","name":"VPJ-Raum_DB sql_vpj_ss18","x":550,"y":1070,"wires":[["80940d0d.aa3f7","9080067f.ac52e8"]]},{"id":"3ef684a6.9b320c","type":"function","z":"c4548fd4.bc53e","name":"Datenabfrage_FROM_orders","func":"var msg = {}; \nmsg.topic= "SELECT COUNT(i_id) FROM Nachbildung_items WHERE i_status = 1 || i_status = 2 || i_status = 3"\nmsg.id = 1;\nmsg.index =1;\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":1070,"wires":[["ac4fcc0d.a31a3"]]},{"id":"36e899a3.b756a6","type":"inject","z":"c4548fd4.bc53e","name":"Items im Prozess","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1000,"wires":[["3ef684a6.9b320c"]]},{"id":"80940d0d.aa3f7","type":"debug","z":"c4548fd4.bc53e","name":"debug_one","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":770,"y":1010,"wires":},{"id":"8c757d81.de401","type":"mysql","z":"c4548fd4.bc53e","mydb":"9ca8d46.70d4c28","name":"VPJ-Raum_DB sql_vpj_ss18","x":540,"y":1190,"wires":[["f70cb265.2b674","9080067f.ac52e8"]]},{"id":"7b094d1c.34e154","type":"function","z":"c4548fd4.bc53e","name":"Datenabfrage_FROM_orders","func":"var msg2 ={};\nmsg2.topic= "SELECT COUNT(o_id) FROM Nachbildung_orders WHERE number_items != number_finished"\nmsg2.id = 2;\nmsg2.index =2;\nreturn msg2;","outputs":1,"noerr":0,"x":250,"y":1190,"wires":[["8c757d81.de401"]]},{"id":"61036f5f.e70a8","type":"inject","z":"c4548fd4.bc53e","name":"Aktive Aufträge","topic":"","payload":"","payloadType":"date","repeat":"7","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1120,"wires":[["7b094d1c.34e154"]]},{"id":"f70cb265.2b674","type":"debug","z":"c4548fd4.bc53e","name":"debug_two","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":770,"y":1280,"wires":},{"id":"15003703.6114c9","type":"function","z":"c4548fd4.bc53e","name":"Auslastung","func":"var items = msg.payload[0]["COUNT(i_id)"];\nvar one = {};\nvar two = {};\n \nvar auslastung = {}; \nauslastung.labels = ["Im Prozess"];\nauslastung.data = [items];\nauslastung.series = ["Anzahl"]; \n\none.payload = msg.payload[0]["COUNT(i_id)"];\none.topic = "line1";\n\ntwo.payload = msg.payload[0]["COUNT(o_id)"];\ntwo.topic = "line2";\n\nreturn [{payload:[auslastung],topic:msg.topic},\n{payload:one},\n{payload:two}];\n","outputs":3,"noerr":0,"x":990,"y":1120,"wires":[["faf8844c.bd76f8"],["b8f20df9.b9a5c","afd08583.eaaf08"],["afd08583.eaaf08","d5077ebf.e91ab"]]},{"id":"69f61b54.1bf774","type":"debug","z":"c4548fd4.bc53e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":990,"y":1010,"wires":},{"id":"9080067f.ac52e8","type":"join","z":"c4548fd4.bc53e","name":"","mode":"custom","build":"string","property":"topic","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"0.1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":1120,"wires":[["69f61b54.1bf774","15003703.6114c9"]]},{"id":"faf8844c.bd76f8","type":"debug","z":"c4548fd4.bc53e","name":"debug_three","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1300,"y":1110,"wires":},{"id":"afd08583.eaaf08","type":"ui_chart","z":"c4548fd4.bc53e","name":"","group":"f87d1db1.35a72","order":0,"width":0,"height":0,"label":"TwoLinesPlease","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1280,"y":1260,"wires":[,]},{"id":"d5077ebf.e91ab","type":"debug","z":"c4548fd4.bc53e","name":"debug_five","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1300,"y":1200,"wires":},{"id":"9ca8d46.70d4c28","type":"MySQLdatabase","z":"","host":"localhost","port":"3306","db":"lokalCCZ","tz":""},{"id":"f87d1db1.35a72","type":"ui_group","z":"","name":"Dynamik","tab":"47eb36d2.cf8678","order":5,"disp":true,"width":"8","collapse":false},{"id":"47eb36d2.cf8678","type":"ui_tab","z":"","name":"Fertigungsprozess mit autonomen Robotinos","icon":"dashboard","order":1}]

The debug-nodes are showing this:
node12
node45

Can somebody help me?

In the last debug output you can see you have msg.payload is an object containing a payload and topic. It should be msg.topic "line2" and msg.payload with the value. You have msg.payload.topic is line2 and msg.payload.payload is 4.

First, thanks for your response.

Here you can see the new contend of my "Auslastung" node:

Blockquote
var items = msg.payload[0]["COUNT(i_id)"];
var one = {};
var two = {};
var auslastung = {};
auslastung.labels = ["Im Prozess"];
auslastung.data = [items];
auslastung.series = ["Anzahl"];
//one.payload = msg.payload[0]["COUNT(i_id)"];
//one.topic = "line1";
one.topic = "line1";
one.payload = msg.payload[0]["COUNT(i_id)"];
//two.payload = msg.payload[0]["COUNT(o_id)"];
//two.topic = "line2";
two.topic = "line2";
two.payload = msg.payload[0]["COUNT(o_id)"];
return [{payload:[auslastung],topic:msg.topic},
{payload:one},
{payload:two}];

I realised that the output of the debug nodes "debug_four" and "debug_five" is changing.

(Please ignore the errors)

Could the join node be the problem?

Maybe another idea or advice?

I would be very grateful

What are you expecting to get out of the join node? You have told it to generate a string.

To generate a string was just a try to make it work. I absolutly don't know how to make it work.. so I tried different ways. Maybe I don't even need the join node.

To make it short, I have no idea :slight_smile:
If you need some more information please tell me

Do you understand the format of the data that you want to provide to the chart?

Not really :neutral_face:

The info tab for the chart has a link to information on how to pre-format data to be passed in as a complete chart.

It's finally working :grinning:
I had to do some changes regarding the topic etc..
And I deleted the join-node. This node was not necessary for my flow.

Thanks for your advice