可根据需求传入data进行动态赋值。

function drawSpeedChat(data) {
    var max = 5120;
    Highcharts.chart("speed_chart", {
        chart : {
            type : 'gauge',
            plotBorderWidth : 0,
            plotShadow : false

        },
        title : {
            text : '平均上传速度'
        },
        credits : {
            enabled : false
        },
        pane : {
            startAngle : -150,
            endAngle : 150,
            background : [ {
                backgroundColor : {
                    linearGradient : {
                        x1 : 0,
                        y1 : 0,
                        x2 : 0,
                        y2 : 1
                    },
                    stops : [ [ 0, '#FFF' ], [ 1, '#333' ] ]
                },
                borderWidth : 0,
                outerRadius : '109%'
            }, {
                backgroundColor : {
                    linearGradient : {
                        x1 : 0,
                        y1 : 0,
                        x2 : 0,
                        y2 : 1
                    },
                    stops : [ [ 0, '#333' ], [ 1, '#FFF' ] ]
                },
                borderWidth : 1,
                outerRadius : '107%'
            }, {
            }, {
                backgroundColor : '#DDD',
                borderWidth : 0,
                outerRadius : '105%',
                innerRadius : '103%'
            } ]
        },
        yAxis : {
            min : 0,
            max : max,
            //minorTickInterval : 'auto',
            minorTickWidth : 1,
            minorTickLength : 10,
            minorTickPosition : 'inside',
            //minorTickColor : '#666',
            tickPixelInterval : 30,
            //tickWidth : 2,
            tickPosition : 'inside',
            tickLength : 13,
            tickColor : '#666',
            tickPositioner: function(){
                return [0, max * 0.1, max * 0.3, max * 0.7, max]
            },
            labels : {
                //step : 2,
                distance: 15,
                rotation : 'auto',
                formatter: function(){
                    if(this.value < 1024){
                        return this.value + 'kb';
                    } else{
                        return (this.value/1024) + 'mb';
                    }
                    
                }
            },
            title : {
                text : 'kb/s'
            },
            plotBands : [{
                from : 0,
                to : max * 0.1,
                color : '#D3D3D3' // green
            }, {
                from : max * 0.1,
                to : max * 0.3,
                color : '#55BF3B' // green
            }, {
                from : max * 0.3,
                to : max * 0.7,
                color : '#DDDF0D' // yellow
            }, {
                from : max * 0.7,
                to : max ,
                color : '#DF5353' // red
            }]
        },
        series : [ {
            name : 'Speed',
            data : [ 407],
            tooltip : {
                valueSuffix : ' kb/s'
            },
            dataLabels: {
                crop: false,
                overflow: 'none'
            }
        } ]
    });

效果如下:
}highcharts做图第一篇,guage速度仪表展示网速

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2021-11-03
  • 2021-04-01
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2022-12-23
  • 2021-07-31
  • 2021-07-12
  • 2021-05-27
  • 2021-12-04
  • 2021-10-03
相关资源
相似解决方案