Here is a flow which shows one of two charts according to button clicks:
[{"id":"63e32070dcc833f1","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"b8d3d59af4f88770","type":"function","z":"63e32070dcc833f1","name":"reformat","func":"let chart = [{\n \"series\": [msg.linetype],\n \"data\": [\n msg.payload.map(d => { return { x: d.timestamp, y: d.value } })\n ],\n \"labels\": []\n}];\nmsg.payload = chart\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":120,"wires":[["f909346a2518cc64"]]},{"id":"f909346a2518cc64","type":"ui_chart","z":"63e32070dcc833f1","name":"Chart","group":"e28f8d1f74fdc75d","order":8,"width":"10","height":"5","label":"{{linetype}}","chartType":"line","legend":"true","xformat":"auto","interpolate":"bezier","nodata":"No Data","dot":false,"ymin":"","ymax":"","removeOlder":"4","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#bf0000","#009500","#005fbd","#c0c0c0","#98df8a","#ff9797","#97cbff","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":650,"y":120,"wires":[[]]},{"id":"36e0cd863925046a","type":"change","z":"63e32070dcc833f1","name":"Fetch Density Data","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"timestamp\":\"2023-03-01T12:00:00.000Z\",\"value\":17},{\"timestamp\":\"2023-03-02T12:00:00.000Z\",\"value\":12},{\"timestamp\":\"2023-03-03T12:00:00.000Z\",\"value\":19.3},{\"timestamp\":\"2023-03-04T12:00:00.000Z\",\"value\":18.04},{\"timestamp\":\"2023-03-05T12:00:00.000Z\",\"value\":10}]","tot":"json"},{"t":"set","p":"linetype","pt":"msg","to":"Drill Mud Density","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":100,"wires":[["b8d3d59af4f88770"]]},{"id":"e0c93a03eb6e2063","type":"change","z":"63e32070dcc833f1","name":"Fetch Depth Data","rules":[{"t":"set","p":"payload","pt":"msg","to":"[{\"timestamp\":\"2023-03-01T12:00:00.000Z\",\"value\":-417.8},{\"timestamp\":\"2023-03-02T12:00:00.000Z\",\"value\":-419.3},{\"timestamp\":\"2023-03-03T12:00:00.000Z\",\"value\":-419.3},{\"timestamp\":\"2023-03-04T12:00:00.000Z\",\"value\":-420.1},{\"timestamp\":\"2023-03-05T12:00:00.000Z\",\"value\":-427.85}]","tot":"json"},{"t":"set","p":"linetype","pt":"msg","to":"Drill Depth","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":140,"wires":[["b8d3d59af4f88770"]]},{"id":"e00e4cf6fa469815","type":"ui_button","z":"63e32070dcc833f1","name":"","group":"e28f8d1f74fdc75d","order":1,"width":"3","height":"1","passthru":false,"label":"Density","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"go","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":40,"wires":[["815b903a5be9574e"]]},{"id":"815b903a5be9574e","type":"trigger","z":"63e32070dcc833f1","name":"","op1":"[]","op2":"0","op1type":"json","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":260,"y":40,"wires":[["f909346a2518cc64"],["36e0cd863925046a"]]},{"id":"8ac5b84fcaa14c42","type":"ui_button","z":"63e32070dcc833f1","name":"","group":"e28f8d1f74fdc75d","order":1,"width":"3","height":"1","passthru":false,"label":"Depth","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"go","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":200,"wires":[["f2029c7f5f90059c"]]},{"id":"f2029c7f5f90059c","type":"trigger","z":"63e32070dcc833f1","name":"","op1":"[]","op2":"0","op1type":"json","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":260,"y":200,"wires":[["f909346a2518cc64"],["e0c93a03eb6e2063"]]},{"id":"e28f8d1f74fdc75d","type":"ui_group","name":"Demo","tab":"45fe9c032a4d03ad","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"45fe9c032a4d03ad","type":"ui_tab","name":"Demo","icon":"","disabled":false,"hidden":false}]