Chart help with data series and colours

There isn't any nice solution but some dirty tricks can be done.

[{"id":"9448cee9.ffa72","type":"inject","z":"3c409e2.49e6162","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":280,"wires":[["93a365c9.c9fca8"]]},{"id":"93a365c9.c9fca8","type":"function","z":"3c409e2.49e6162","name":"generate data","func":"var t = Math.floor(Math.random()*2)+1 === 1 ? \"first\" : \"second\"\nmsg.topic = t\nmsg.payload = Math.floor(Math.random()*6)\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":280,"wires":[["d1e96723.c0ebd8"]]},{"id":"e4105fc8.13de","type":"ui_chart","z":"3c409e2.49e6162","name":"","group":"a62a0f79.cccc6","order":2,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"bezier","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":700,"y":280,"wires":[[],[]]},{"id":"d1e96723.c0ebd8","type":"function","z":"3c409e2.49e6162","name":"ensure the first","func":"// if you are using presistable context storage only\n// then you should probably activate memory option too\n// and store this firstTopic in memory only.\n// otherwise after reload/restart the  \n// value of firstTopic will be filled from previous sessiom\n// and this function does nothing  \nvar firstTopic = context.get(\"firstTopic\")\n\n//you'll need to know the name of topic youll need as the first one\nif(msg.topic === \"first\" && msg.topic !== firstTopic){\n    firstTopic = msg.topic;\n    context.set(\"firstTopic\",firstTopic);\n    return msg\n}\nif(msg.topic !== \"first\" && firstTopic !== \"first\"){\n   // any other topic filtered out if first  topic is not seen yet\n   return\n}\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":280,"wires":[["e4105fc8.13de"]]},{"id":"a62a0f79.cccc6","type":"ui_group","z":"","name":"ILM","tab":"c557d8de.586c48","order":2,"disp":false,"width":"20","collapse":false},{"id":"c557d8de.586c48","type":"ui_tab","z":"","name":"MAIN","icon":"dashboard","order":1}]
1 Like