web前端显示设备实时温度,ECharts实现温度折线图,实时动态温度曲线图生成

web前端显示设备实时温度,ECharts实现温度折线图,实时动态温度曲线图生成。

web前端显示设备实时温度,ECharts实现温度折线图,实时动态温度曲线图生成。

具体步骤如下:

1.在页面中引入ECharts文件echarts-all.js

 <!-- ECharts单文件引入 -->
<script src="http://echarts.baidu.com/build/dist/echarts-all.js"></script>

2.在body中为ECharts准备一个具备大小(宽高)的Dom

<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="height:400px"></div>

3.具体JS代码如下:

<script>
    // 基于准备好的dom,初始化echarts图表
    var myChart = echarts.init(document.getElementById('main'));

    //折线图数据
    var option = {
        title : {
            text: '设备1温度显示',
            subtext: ''
        },
        tooltip : {
            trigger: 'axis'
        },
        legend: {
            //data:['最高温度','最低温度']
   data:['温度']
        },
        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                magicType : {show: true, type: ['line', 'bar']},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : true,
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                data : ['周一','周二','周三','周四','周五','周六','周日']
            }
        ],
        yAxis : [
            {
                type : 'value',
                axisLabel : {
                    formatter: '{value} °C'
                }
            }
        ],
        series : [
            {
                name:'温度',
                type:'line',
                data:[11, 11, 15, 13, 12, 13, 10],
                markPoint : {
                    data : [
                        {type : 'max', name: '最大值'},
                        {type : 'min', name: '最小值'}
                    ]
                },
                markLine : {
                    data : [
                        {type : 'average', name: '平均值'}
                    ]
                }
            }
   /*,
            {
                name:'最低气温',
                type:'line',
                data:[1, -2, 2, 5, 3, 2, 0],
                markPoint : {
                    data : [
                        {name : '周最低', value : -2, xAxis: 1, yAxis: -1.5}
                    ]
                },
                markLine : {
                    data : [
                        {type : 'average', name : '平均值'}
                    ]
                }
            }*/
        ]
    };

可显示最高温度、最低温度、平均值。

// 为echarts对象加载数据
myChart.setOption(option);

125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/3523.html

(8)
江山如画的头像江山如画管理团队
上一篇 2019年5月11日 上午10:34
下一篇 2019年6月5日 上午9:43

99%的人还看了以下文章

  • Undefined variable: file python3不再支持file函数

    python处理文件时,使用file函数,提示错误:Undefined variable: file 反复查看语法,没有问题啊,最后查找到原因: python3不再支持file函数 替代方法:可以用open代替file 函数。

    2019年3月29日
    8.6K0
  • ASP.NET(C#)学习笔记一:注释、常量与变量

    ASP.NET(C#)的注释 多行注释: /* */ 单行注释: //计算圆的面积:Pi*r*r 实例1:注释的使用 /*以下程序由www.125jz.com站长于2018.1.30日开发,测试通过。     完成功能:计算圆的面积*/     public partial class W…

    2018年1月30日
    5.4K0
  • opencv_python-4.4.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform

    ERROR: opencv_python-4.4.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform. WARNING: You are using pip version 20.2.3; however, version 20.3.1 is available.You sh…

    编程开发 2020年12月8日
    5.4K0
  • python 集合的使用,案例详解

    集合的定义: 1.不同元素组成 2.无序 3.集合中的元素必须是不可变类型 创建集合 s = {1,2,3,4,5,6,7,8} >>> set_test = set(‘hello’) >>> set_test {‘h’, ‘l’, ‘e’, ‘o’}  # 由此可见集合中的元素不可重复,都是不同的 集合运算 集合之间也可…

    2020年1月22日
    11.2K0
  • python 实战-逢7 过游戏的实现

    不知道你有没有玩过“逢 7 过”的游戏,游戏规则很简单: 几个人轮流报数,凡遇到 7 的倍数,或含 7 的数字就要跳过,否则就算失败。 今天我们就用 Python 来打印 1 到 100 之间,所有满足条件的数字。 知识点 Python 开发环境 int 类型 变量 运算符 while 循环 条件判断 💡提示: 开发中,我们经常要先构思框架,…

    2022年2月2日
    9.3K0
  • itbegin编程教学云课堂使用介绍

    进入https://www.itbegin.com/apps    点击右上角 登录 登录后,点击院校通–院校 点击进入个人中心 点击“web开发技术课堂”,进入相应课程 点击:我的预习,可以看到预习的知识点,时间要求。请同学们一定要在结束时间前完成任务! 点击查看,可以看到需要预习的知识点,预习以观察,查看效果为主。 如要求:观察各标签的使用及…

    2018年3月14日
    7.5K0

发表回复

登录后才能评论

评论列表(1条)

  • 青红皂了个白的头像
    青红皂了个白 2019年9月27日 下午5:04

    感谢