I am hiding selected lines on a chart (by nullifying that element of the chart data array and redrawing)
This works, and I can have a Reset button to redraw all the lines. Except...
If I hide all the lines on the chart, I can't unhide them without reloading the page.
Any ideas why not?
(Sorry the Gif is a big file, don't know the right way to record the screen for posting)
[{"id":"30306197ead446be","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"69fe9ae270120706","type":"function","z":"30306197ead446be","name":"Format chart","func":"const chart = [{\n \"series\": [\"Line 1\", \"Line 2\", \"Line 3\"],\n \"data\": [\n msg.payload.map(d => { return { x: d.timestamp, y: d.data1 } }), \n msg.payload.map(d => { return { x: d.timestamp, y: d.data2 } }), \n msg.payload.map(d => { return { x: d.timestamp, y: d.data3 } }),\n ],\n \"labels\": []\n}];\n\nlet showline1 = flow.get(\"showline1\") ?? true\nlet showline2 = flow.get(\"showline2\") ?? true\nlet showline3 = flow.get(\"showline3\") ?? true\nif (showline1 === false) { chart[0].data[0] = [] }\nif (showline2 === false) { chart[0].data[1] = [] }\nif (showline3 === false) { chart[0].data[2] = [] }\nmsg.payload = chart\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":120,"wires":[["314f11b8ce2f85f3"]]},{"id":"314f11b8ce2f85f3","type":"ui_chart","z":"30306197ead446be","name":"Chart","group":"a664f24e9358412a","order":8,"width":"8","height":"5","label":"Show/Hide Lines","chartType":"line","legend":"true","xformat":"auto","interpolate":"bezier","nodata":"No Data","dot":false,"ymin":"4","ymax":"12","removeOlder":"52","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#bf0000","#009500","#005fbd","#c0c0c0","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":870,"y":120,"wires":[[]]},{"id":"928f4ec23ec08672","type":"inject","z":"30306197ead446be","name":"Redraw","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":80,"wires":[["08f4db4969c00428"]]},{"id":"06a5e73dfc6b1cb2","type":"ui_template","z":"30306197ead446be","group":"a664f24e9358412a","name":"","order":1,"width":0,"height":0,"format":"<style>\n .hide {\n display: none;\n } \n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":860,"y":80,"wires":[[]]},{"id":"58bda8febf19fd51","type":"ui_button","z":"30306197ead446be","name":"","group":"a664f24e9358412a","order":2,"width":"2","height":"1","passthru":false,"label":"Line 1","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"toggle","payloadType":"str","topic":"line1","topicType":"str","x":90,"y":80,"wires":[["94876dd0e4e71f54"]]},{"id":"367c887713066934","type":"ui_button","z":"30306197ead446be","name":"","group":"a664f24e9358412a","order":2,"width":"2","height":"1","passthru":false,"label":"Line 2","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"toggle","payloadType":"str","topic":"line2","topicType":"str","x":90,"y":120,"wires":[["ace0dbd65cb63e1a"]]},{"id":"8d5217d7939b16a9","type":"ui_button","z":"30306197ead446be","name":"","group":"a664f24e9358412a","order":2,"width":"2","height":"1","passthru":false,"label":"Line 3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"toggle","payloadType":"str","topic":"line3","topicType":"str","x":90,"y":160,"wires":[["165cd2e77566b1da"]]},{"id":"08f4db4969c00428","type":"function","z":"30306197ead446be","name":"Simulate db request","func":"msg.payload = [\n{ \"id\": 1, \"timestamp\": \"2022-12-20T01:00:00.000Z\", \"data1\": 5.01, \"data2\": 10.70, \"data3\": 10.47, },\n{ \"id\": 2, \"timestamp\": \"2022-12-20T02:00:00.000Z\", \"data1\": 5.01, \"data2\": 10.46, \"data3\": 10.07, },\n{ \"id\": 3, \"timestamp\": \"2022-12-20T03:00:00.000Z\", \"data1\": 5.01, \"data2\": 10.20, \"data3\": 8.93, },\n{ \"id\": 4, \"timestamp\": \"2022-12-20T04:00:00.000Z\", \"data1\": 5.01, \"data2\": 10.41, \"data3\": 7.90, },\n{ \"id\": 5, \"timestamp\": \"2022-12-20T05:00:00.000Z\", \"data1\": 5.01, \"data2\": 11.04, \"data3\": 7.49, },\n{ \"id\": 6, \"timestamp\": \"2022-12-20T06:00:00.000Z\", \"data1\": 4.68, \"data2\": 11.41, \"data3\": 6.88, },\n{ \"id\": 7, \"timestamp\": \"2022-12-20T07:00:00.000Z\", \"data1\": 4.68, \"data2\": 11.41, \"data3\": 6.39, },\n{ \"id\": 8, \"timestamp\": \"2022-12-20T08:00:00.000Z\", \"data1\": 4.68, \"data2\": 11.41, \"data3\": 5.72, },\n{ \"id\": 9, \"timestamp\": \"2022-12-20T09:00:00.000Z\", \"data1\": 4.68, \"data2\": 11.41, \"data3\": 5.72, },\n{ \"id\": 10, \"timestamp\": \"2022-12-20T10:00:00.000Z\", \"data1\": 4.68, \"data2\": 11.41, \"data3\": 6.62, }]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":120,"wires":[["69fe9ae270120706"]]},{"id":"ace0dbd65cb63e1a","type":"function","z":"30306197ead446be","name":"function 28","func":"let showline = flow.get(\"showline2\") ?? true\nshowline = showline ? false : true\nflow.set(\"showline2\", showline)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":120,"wires":[["08f4db4969c00428"]]},{"id":"165cd2e77566b1da","type":"function","z":"30306197ead446be","name":"function 30","func":"let showline = flow.get(\"showline3\") ?? true\nshowline = showline ? false : true\nflow.set(\"showline3\", showline)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":160,"wires":[["08f4db4969c00428"]]},{"id":"94876dd0e4e71f54","type":"function","z":"30306197ead446be","name":"function 31","func":"let showline = flow.get(\"showline1\") ?? true\nshowline = showline ? false : true\nflow.set(\"showline1\", showline)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":80,"wires":[["08f4db4969c00428"]]},{"id":"4a1fc62260e0f6f3","type":"ui_button","z":"30306197ead446be","name":"","group":"a664f24e9358412a","order":2,"width":"2","height":"1","passthru":false,"label":"Reset","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"toggle","payloadType":"str","topic":"","topicType":"str","x":90,"y":200,"wires":[["2792e0aee697571f"]]},{"id":"2792e0aee697571f","type":"function","z":"30306197ead446be","name":"function 32","func":"flow.set(\"showline1\", true)\nflow.set(\"showline2\", true)\nflow.set(\"showline3\", true)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":200,"wires":[["08f4db4969c00428"]]},{"id":"a664f24e9358412a","type":"ui_group","name":"Demo","tab":"7d501f2d3ff3af24","order":1,"disp":true,"width":"8","collapse":false,"className":""},{"id":"7d501f2d3ff3af24","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]