vue echarts仪表盘渐变色

效果如图

 

 

复制代码
    // this.$echarts 为 echarts对象,该代码是使用在vue中的
       let option4 = {
            series: [
                {
                type: 'gauge',
                center: ['40%', '60%'],
                startAngle: 200,
                endAngle: -20,
                min: 0,
                max: 60,
                splitNumber: 7,
                itemStyle: {
                    color: new this.$echarts.graphic.LinearGradient(0,0,1,0,[
                        {
                            offset: 0.1,
                            color: "#FFC600"
                        },
                        {
                            offset: 0.6,
                            color: "#30D27C"
                        },
                        {
                            offset: 1,
                            color: "#0B95FF"
                        }
                    ]),
                },
                progress: {
                    show: true,
                    width: 5
                },
                pointer: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        width: 30,
                        color:'#FFAB91'
                    }
                },
                axisTick: {
                    distance: -45,
                    splitNumber: 9,
                    lineStyle: {
                        width: 1,
                        color: new this.$echarts.graphic.LinearGradient(0,0,1,0,[
                            {
                                offset: 0.1,
                                color: "#FFC600"
                            },
                            {
                                offset: 0.6,
                                color: "#30D27C"
                            },
                            {
                                offset: 1,
                                color: "#0B95FF"
                            }
                        ]),
                    }
                },
                splitLine: {
                    distance: -52,
                    length: 11,
                    lineStyle: {
                        width: 2,
                        color: new this.$echarts.graphic.LinearGradient(0,0,1,0,[
                            {
                                offset: 0.1,
                                color: "#FFC600"
                            },
                            {
                                offset: 0.6,
                                color: "#30D27C"
                            },
                            {
                                offset: 1,
                                color: "#0B95FF"
                            }
                    ]),
                    }
                },
                axisLabel: {
                    distance: -20,
                    color: new this.$echarts.graphic.LinearGradient(0,0,1,0,[
                            {
                                offset: 0.1,
                                color: "#FFC600"
                            },
                            {
                                offset: 0.6,
                                color: "#30D27C"
                            },
                            {
                                offset: 1,
                                color: "#0B95FF"
                            }
                        ]),
                    fontSize: 0
                },
                anchor: {
                    show: false
                },
                title: {
                    show: true
                },
          // 图中的34%是我另外添加的,把下面的show设置为true可以显示自带的数字
                detail: {
                    valueAnimation: true,
                    width: '60%',
                    lineHeight: 40,
                    borderRadius: 8,
                    offsetCenter: [0, '-15%'],
                    fontSize: 10,
                    fontWeight: 'bolder',
                    formatter: '{value}',
                    color: '#FFAB91',
                    show:false
                },
                data: [
                    {
                        value: 100
                    }
                ]
                }
            ]
        };    
复制代码

 

posted @   zy-lzh  阅读(962)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
点击右上角即可分享
微信分享提示