SQL(`select time, value from example where name = ? limit 2`,"TAG0")CHART(chartOption({xAxis:{data:column(0)},yAxis:{},series:{type:"bar",data:column(1)}}))
HTTP GET
Open web browser with http://127.0.0.1:5654/db/tql/output-chart.tql
The legacy CHART_LINE(), CHART_BAR(), CHART_SCATTER() and its family functions are deprecated
with the new CHART() function.
Please refer to the CHART() for the examples.
CHART with chartJson()
Save tql file
Save the code below as output-chart.tql.
1
2
3
4
5
6
7
8
9
SQL(`select time, value from example where name = ? limit 2`,"TAG0")CHART(chartJson(true),chartOption({xAxis:{data:column(0)},yAxis:{},series:{type:"bar",data:column(1)}}))
HTTP GET
Open web browser with http://127.0.0.1:5654/db/tql/output-chart.tql
SQL(`select time, value from example where name = ? limit 2`,"TAG0")CHART(chartID("myChart"),chartJson(true),chartOption({xAxis:{data:column(0)},yAxis:{},series:{type:"bar",data:column(1)}}))
HTTP GET
Open web browser with http://127.0.0.1:5654/db/tql/output-chart.tql
This scenario is useful when your DOM document has <div id='myChart'/>.
... in HTML ...
<divid='myChart'/><script>fetch('http://127.0.0.1:5654/db/tql/output-chart.tql').then(function(rsp){returnrsp.json();}).then(function(c){c.jsAssets.concat(c.jsCodeAssets).forEach((src)=>{constsScript=document.createElement('script');sScript.src=src;sScript.type='text/javascript';document.getElementsByTagName('head')[0].appendChild(sScript);})})</script>... omit ...