首页 > 其他 > 详细

使用echart仪表盘

时间:2019-08-07 16:03:19      阅读:428      评论:0      收藏:0      [点我收藏+]

html代码

技术分享图片
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>温度仪表盘</title>
    <script type="text/javascript" src="js/echarts.js"></script>
    <script type="text/javascript">
        window.onload=function(){
            var myChart = echarts.init(document.getElementById(temperature));
            option = {
                tooltip : {
                    formatter: "{a} <br/>{b} : {c}℃"
                },
                series: [
                    {
                        name: 温度,
                        type: gauge,
                        min:50,//最小值
                        max:60,//最大值
                        splitNumber:20, //刻度的个数
                        radius:"100%",//大小
                        pointer:{  //指针
                            width:3,
                            length:90%,
                        },
                        axisLabel:{ //刻度的大小
                            textStyle:{
                                fontSize:7,
                            },
                        },
                        axisLine:{ //外轮廓的宽度
                            lineStyle:{
                                width:15,
                            }
                        },
                        splitLine:{ //刻度线的长度和宽度
                            length:15,
                            lineStyle:{
                                width:1,
                            }
                        },
                        detail: { 
                            formatter:{value}℃,
                            textStyle:{ //当前温度的文字大小
                                fontSize:12
                            },
                        },
                        data: [{
                            value: 50, 
                            name: 温度,
                        }]
                    }
                ]
            };

            setInterval(function () {
                option.series[0].data[0].value = randomFrom(50,60);
                myChart.setOption(option, true);
            },2000);
        }
        function randomFrom(lowerValue,upperValue)
        {
             return (Math.random() * (upperValue - lowerValue + 1)+ lowerValue).toFixed(1);
        }
    </script>
</head>
<body>
    <div id="temperature" style="width:300px;height: 300px"></div>
</body>
</html>
View Code

 技术分享图片

 

使用echart仪表盘

原文:https://www.cnblogs.com/xifengmo/p/11315812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!