Ui_chart alternate (Apex chart ?) Just want the zoom feature in the graph

Apexchart example Flow based on your data
(with some $random values added to simulated and test the chart update)

[{"id":"c0c284e2d249d05c","type":"change","z":"54efb553244c241f","name":"sample data from mysql query","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"d\":\"2023-03-21T00:29:00.000Z\",\t       \"Temperature\":103 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:28:00.000Z\",\t       \"Temperature\":103 + $random()*80,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1185+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:27:00.000Z\",\t       \"Temperature\":103 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:26:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1161\t   },\t   {\t       \"d\":\"2023-03-21T00:25:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:24:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:23:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:22:00.000Z\",\t       \"Temperature\":104 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:21:00.000Z\",\t       \"Temperature\":105 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:20:00.000Z\",\t       \"Temperature\":104,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1161\t   },\t   {\t       \"d\":\"2023-03-21T00:19:00.000Z\",\t       \"Temperature\":104,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1161\t   },\t   {\t       \"d\":\"2023-03-21T00:18:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1161\t   },\t   {\t       \"d\":\"2023-03-21T00:17:00.000Z\",\t       \"Temperature\":102 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:16:00.000Z\",\t       \"Temperature\":102 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:15:00.000Z\",\t       \"Temperature\":103 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:14:00.000Z\",\t       \"Temperature\":103 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:13:00.000Z\",\t       \"Temperature\":101 + $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:12:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090\t   },\t   {\t       \"d\":\"2023-03-21T00:11:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:10:00.000Z\",\t       \"Temperature\":104,\t       \"m1\":500 + $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:09:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090\t   },\t   {\t       \"d\":\"2023-03-21T00:08:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:07:00.000Z\",\t       \"Temperature\":102+ $random()*80,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:06:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:05:00.000Z\",\t       \"Temperature\":101+ $random()*80,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-21T00:04:00.000Z\",\t       \"Temperature\":100,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:03:00.000Z\",\t       \"Temperature\":99,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:02:00.000Z\",\t       \"Temperature\":100,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-21T00:01:00.000Z\",\t       \"Temperature\":100,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-21T00:00:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:59:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090\t   },\t   {\t       \"d\":\"2023-03-20T23:58:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:57:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-20T23:56:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:55:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-20T23:54:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:53:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1066\t   },\t   {\t       \"d\":\"2023-03-20T23:52:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-20T23:51:00.000Z\",\t       \"Temperature\":101,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-20T23:50:00.000Z\",\t       \"Temperature\":99,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":450\t   },\t   {\t       \"d\":\"2023-03-20T23:49:00.000Z\",\t       \"Temperature\":100,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090\t   },\t   {\t       \"d\":\"2023-03-20T23:48:00.000Z\",\t       \"Temperature\":102+ $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:47:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1066\t   },\t   {\t       \"d\":\"2023-03-20T23:46:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:45:00.000Z\",\t       \"Temperature\":104+ $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:44:00.000Z\",\t       \"Temperature\":104,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1090\t   },\t   {\t       \"d\":\"2023-03-20T23:43:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:42:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:41:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:40:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:39:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:38:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:37:00.000Z\",\t       \"Temperature\":103+ $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:36:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:35:00.000Z\",\t       \"Temperature\":103,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:34:00.000Z\",\t       \"Temperature\":102+ $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113\t   },\t   {\t       \"d\":\"2023-03-20T23:33:00.000Z\",\t       \"Temperature\":102,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:32:00.000Z\",\t       \"Temperature\":102+ $random()*80,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1113+ $random()*80\t   },\t   {\t       \"d\":\"2023-03-20T23:31:00.000Z\",\t       \"Temperature\":101+ $random()*80,\t       \"m1\":500+ $random()*80,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137\t   },\t   {\t       \"d\":\"2023-03-20T23:30:00.000Z\",\t       \"Temperature\":101+ $random()*80,\t       \"m1\":500,\t       \"r\":\"2023-03-19T18:30:00.000Z\",\t       \"flow\":1137+ $random()*80\t   }\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":2540,"wires":[["48b1a74d08f4027a"]]},{"id":"c0956cc7d767a4ee","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":2540,"wires":[["c0c284e2d249d05c"]]},{"id":"1dcfd28829eeec92","type":"debug","z":"54efb553244c241f","name":"debug 261","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":2480,"wires":[]},{"id":"afed9f5b8af7b455","type":"ui_template","z":"54efb553244c241f","group":"0df4552f9d69039d","name":"","order":1,"width":"12","height":"12","format":"<script src=\"https://cdn.jsdelivr.net/npm/apexcharts\"></script>\n<div id=\"chart\"></div>\n\n<script>\n  (function(scope) {\n  scope.$watch('msg', function(msg) {\n    if (msg) {\n      // Do something when msg arrives\n     var options = {\n          series: msg.payload,\n          chart: {\n          type: 'line',\n          stacked: false,\n          // height: 350,\n          zoom: {\n            type: 'x',\n            enabled: true,\n            autoScaleYaxis: true\n          },\n          toolbar: {\n            autoSelected: 'zoom'\n          }\n        },\n         dataLabels: {\n           enabled: false\n         },\n         markers: {\n           size: 0,\n         },\n        title: {\n          text: 'Flow and Temp Data',\n          align: 'left'\n        },\n        // fill: {\n        //   type: 'gradient',\n        //   gradient: {\n        //     shadeIntensity: 1,\n        //     inverseColors: false,\n        //     opacityFrom: 0.5,\n        //     opacityTo: 0,\n        //     stops: [0, 90, 100]\n        //   },\n        // },\n         yaxis: {\n           labels: {\n             formatter: function (val) {\n               return val.toFixed(2);\n             },\n           },\n          // title: {\n          //   text: 'Price'\n          // },\n         },\n        xaxis: {\n          type: 'datetime',\n        },\n        // tooltip: {\n          // shared: false,\n          // y: {\n          //   formatter: function (val) {\n          //     return (val / 1000000).toFixed(0)\n          //   }\n          // }\n        // }\n        };\n\nsetTimeout( ()=> {\n\n    if(scope.chart){\n      scope.chart.updateOptions(options)\n    }\n    else {\n      scope.chart = new ApexCharts(document.querySelector(\"#chart\"), options);\n      scope.chart.render();\n    }\n    \n}, 1000)\n\n    }\n  });\n})(scope);\n</script>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":900,"y":2540,"wires":[[]]},{"id":"48b1a74d08f4027a","type":"change","z":"54efb553244c241f","name":"Prepare Chart Data","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t       {\t           \"name\" : \"Holding Temperature\",\t           \"data\" : payload.{\"x\": $.d, \"y\": $.Temperature}\t    },\t       {\t           \"name\" : \"Divert Valve Status\",\t           \"data\" : payload.{\"x\": $.d, \"y\": $.m1}\t    },\t       {\t           \"name\" : \"Flow Rate\",\t           \"data\" : payload.{\"x\": $.d, \"y\": $.flow}\t    }\t]\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":2540,"wires":[["1dcfd28829eeec92","afed9f5b8af7b455"]]},{"id":"0df4552f9d69039d","type":"ui_group","name":"DEFAULT","tab":"f3a8a67ff0904e39","order":1,"disp":false,"width":"12","collapse":false,"className":""},{"id":"f3a8a67ff0904e39","type":"ui_tab","name":"HOME","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

image

2 Likes