1. 程式人生 > 其它 >echarts gauge儀表盤配置

echarts gauge儀表盤配置

option = {
    tooltip : {
        formatter: "{a} <br/>{b} : {c}%"
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    series : [
        {
            name:'業務指標',
            type:'gauge',
            splitNumber: 10,       // 分割段數,預設為5
            axisLine: {            // 座標軸線
                lineStyle: {       // 屬性lineStyle控制線條樣式
                    color: [[0.2, '#228b22'],[0.8, '#48b'],[1, '#ff4500']], 
                    width: 8
                }
            },
            axisTick: {            // 座標軸小標記
                splitNumber: 10,   // 每份split細分多少段
                length :12,        // 屬性length控制線長
                lineStyle: {       // 屬性lineStyle控制線條樣式
                    color: 'auto'
                }
            },
            axisLabel: {           // 座標軸文字標籤,詳見axis.axisLabel
                textStyle: {       // 其餘屬性預設使用全域性文字樣式,詳見TEXTSTYLE
                    color: 'auto'
                }
            },
            splitLine: {           // 分隔線
                show: true,        // 預設顯示,屬性show控制顯示與否
                length :30,         // 屬性length控制線長
                lineStyle: {       // 屬性lineStyle(詳見lineStyle)控制線條樣式
                    color: 'auto'
                }
            },
            pointer : {    //指標大小
                width : 5
            },
            title : {
                show : true,
                offsetCenter: [0, '-40%'],       // x, y,單位px
                textStyle: {       // 其餘屬性預設使用全域性文字樣式,詳見TEXTSTYLE
                    fontWeight: 'bolder'
                }
            },
            detail : {
                formatter:'{value}%',
                textStyle: {       // 其餘屬性預設使用全域性文字樣式,詳見TEXTSTYLE
                    color: 'auto',
                    fontWeight: 'bolder'
                }
            },
            data:[{value: 50, name: '完成率'}]
        }
    ]
};

clearInterval(timeTicket);
timeTicket = setInterval(function (){
    option.series[0].data[0].value = (Math.random()*100).toFixed(2) - 0;
    myChart.setOption(option,true);
},2000)