|
发表于 2022-8-11 10:32:06
|
显示全部楼层
本帖最后由 fryefryefrye 于 2022-8-11 10:45 编辑
理论上可以。
先把一个模板html放在8266的文件系统,开web服务。
浏览器访问后,会打开这个html模板。
然后html有脚本通过web地址访问数据,你在web服务里做一下,某个地址,返回所有的数据。
图就能画出来了。
- <html>
- <head>
- <title>测试标题</title>
- <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
- <script src="http://code.highcharts.com/highcharts.js"></script>
- <script src="http://code.highcharts.com/modules/data.js"></script>
- </head>
- <body>
- <div id="container" style="width: 850px; height: 400px; margin: 0 auto"></div>
- <script language="JavaScript">
- $(document).ready(function() {
- var chart = {
- //type: 'scatter',
- zoomType: 'x'
- };
- var title = {
- text: '测试名称'
- };
- var subtitle = {
- text: 'Source: xxx'
- };
- var xAxis = {
- tickInterval: 60 * 1000, // time interval of xAxis in ms
- tickWidth: 0,
- gridLineWidth: 1,
- labels: {
- align: 'left',
- x: 3,
- y: -3
- }
- };
- var yAxis = [{ // 左边 Y 轴
- title: {
- text: null
- },
- labels: {
- align: 'left',
- x: 3,
- y: 16,
- format: '{value:.,0f}'
- },
- showFirstLabel: false
- },{ // 右边 Y 轴
- linkedTo: 0,
- gridLineWidth: 0,
- opposite: true,
- title: {
- text: null
- },
- labels: {
- align: 'right',
- x: -3,
- y: 16,
- format: '{value:.,0f}'
- },
- showFirstLabel: false
- }
- ];
- var tooltip = {
- shared: true,
- crosshairs: true
- }
- var legend = {
- align: 'left',
- verticalAlign: 'top',
- y: 20,
- floating: true,
- borderWidth: 0
- };
-
- var json = {};
- json.chart = chart;
- json.title = title;
- json.subtitle = subtitle;
- json.xAxis = xAxis;
- json.yAxis = yAxis;
- json.tooltip = tooltip;
- json.legend = legend;
- $.get('dailychartdata', function (csv) {
- var data = {
- csv: csv
- };
- json.data = data;
- $('#container').highcharts(json);
- });
- });
- </script>
- </body>
- </html>
复制代码- 模板文件第87行的URL地址,请求数据的时候,按以下格式返回数据即可。
- 一根线数据格式示例:
- 2021-08-20 23:59:01,1
- 2021-08-21 23:59:00,2
- 2021-08-22 23:59:01,2
- 2021-08-23 23:59:00,1
- 2021-08-24 23:59:01,1
- 2021-08-25 23:59:00,1
复制代码
|
|