echarts仪表盘,实时电压显示

该博客内容展示了如何使用Echarts库创建一个实时电压显示的仪表盘。通过配置多个系列,如最外部进度条、刻度尺、外部指针和内层带指针,实现了不同层次和样式的仪表盘元素。仪表盘包含动态更新的指针,以及自定义的颜色渐变和标签样式,以清晰地展示实时电压数据。
摘要由CSDN通过智能技术生成

echarts仪表盘,实时电压显示

在这里插入图片描述`const dataArr = 385;
const dataX = 440;
const height1 = {value:600};
option = {
backgroundColor: ‘#031f45’,
/** 标题*/
title: [
{
text:
‘{val|’ + 385+ ‘}\n{name|’ + ‘实时电压’ + ‘}{unit|(’ + ‘’ + ‘)}’,
bottom: ‘32%’,
left: ‘center’,
textStyle: {
rich: {
val: {
fontSize:‘24’,
color: ‘#E5E5E5’,
padding: [10, 0],
},
name: {
fontSize: ‘18’,
color: ‘#E5E5E5’,
},
unit: {
fontSize:‘14’,
color: ‘#DCCC5F’,
},
},
},
triggerEvent: true,
},
],

/** 关闭必图例*/
legend: {
    show: false,
},
series: [
    {
        name: '最外部进度条',
        type: 'gauge',
        radius: '90%',
        splitNumber: 10,
        axisLine: {
            lineStyle: {
                color: [
                    [
                        dataArr / dataX,
                        {
                            type: 'linear',
                            x: 0,
                            y: 1,
                            x2: 0.5,
                            y2: 0.5,
                            colorStops: [
                                {
                                    offset: 0,
                                    color: 'rgba(0,0,0,0)', // 0% 处的颜色
                                },
                                {
                                    offset: 0.8,
                                    color: '#583043', // 100% 处的颜色
                                },
                                {
                                    offset: 1,
                                    color: '#faad14', // 100% 处的颜色
                                },
                            ],
                            global: false, // 缺省为 false
                        },
                    ],
                    [1, '#083158'],
                ],
                width: 10,
            },
        },
        axisLabel: {
            show: false,
        },
        axisTick: {
            show: false,
        },
        splitLine: {
            show: false,
        },
        itemStyle: {
            show: false,
        },
        detail: {
            show: false,
        },
        title: {
            // 标题
            show: false,
        },
        data: [
            {
                name: 'title',
                value: dataArr,
            },
        ],
        pointer: {
            show: false,
        },
        animationDuration: 4000,
    },

    {
        name: '刻度尺',
        type: 'gauge',
        radius: '81%',
        splitNumber: 10, // 刻度数量
        min: 0, // 最小刻度
        max: dataX, // 最大刻度
        // 仪表盘轴线相关配置
        axisLine: {
            lineStyle: {
                color: [
                    [
                        1,
                        {
                            type: 'radial',
                            x: 0.5,
                            y: 0.6,
                            r: 0.6,
                            colorStops: [
                                {
                                    offset: 0.85,
                                    color: '#031F46', // 0% 处的颜色
                                },
                                {
                                    offset: 0.93,
                                    color: '#086989', // 100% 处的颜色
                                },
                                {
                                    offset: 1,
                                    color: '#12D7EF', // 100% 处的颜色
                                },
                            ],
                        },
                    ],
                ],
                width: 500,
            },
        },
        /** 分隔线样式*/
        splitLine: {
            show: true,
            length: 14,
            lineStyle: {
                width: 3,
                color: '#12E5FE', // 用颜色渐变函数不起作用
            },
        },
        /** 刻度线*/
        axisTick: {
            show: true,
            splitNumber: 20,
            lineStyle: {
                color: '#12E5FE', // 用颜色渐变函数不起作用
                width: 1,
            },
            length: 5,
        },
        /** 刻度标签*/
        axisLabel: {
            distance: 2,
            color: '#CEF3FE',
        },
        detail: {
            show: false,
        },
        animationDuration: 4000,
    },
    {
        name: '外部指针',
        type: 'gauge',
        radius: '90%',
        axisLine: {
            lineStyle: {
                color: [
                    [dataArr / dataX - 0.001, 'rgba(0,0,0,0)'],
                    [dataArr / dataX + 0.003, '#faad14'],
                    [1, 'rgba(0,0,0,0)'],
                ],
                width: 33,
            },
        },
        axisLabel: {
            show: false,
        },
        axisTick: {
            show: false,
        },
        splitLine: {
            show: false,
        },
        itemStyle: {
            show: false,
        },
        detail: {
            show: false,
        },
        title: {
            // 标题
            show: false,
        },
        data: [
            {
                name: 'title',
                value: dataArr,
            },
        ],
        pointer: {
            show: false,
        },
        animationDuration: 4000,
    },
    {
        name: '内层带指针',
        type: 'gauge',
        radius: '61%',
        splitNumber: 10, // 刻度数量
        min: 0, // 最小刻度
        max: dataX, // 最大刻度
        // 仪表盘轴线相关配置
        axisLine: {
            lineStyle: {
                color: [
                    [
                        1,
                        {
                            type: 'radial',
                            x: 0.5,
                            y: 0.59,
                            r: 0.6,
                            colorStops: [
                                {
                                    offset: 0.72,
                                    color: '#032046',
                                },
                                {
                                    offset: 0.94,
                                    color: '#086989',
                                },
                                {
                                    offset: 0.98,
                                    color: '#0FAFCB',
                                },
                                {
                                    offset: 1,
                                    color: '#0EA4C1',
                                },
                            ],
                        },
                    ],
                ],
                width: 1000,
            },
        },
        /** 分隔线样式*/
        splitLine: {
            show: false,
        },
        /** 刻度线*/
        axisTick: {
            show: false,
        },
        /** 刻度标签*/
        axisLabel: {
            show: false,
        },
        /** 仪表盘指针*/
        pointer: {
            show: true,
            length: '95%',
            width: 5, // 指针粗细
        },
        /** 仪表盘指针样式*/
        itemStyle: {
            color: '#12E5FF',
        },
        data: [
            {
                value: dataArr,
            },
        ],
        detail: {
            show: false,
        },
    },
],
graphic: {
    elements: [
        {
            type: 'line',
            z: 4,
            style: {
                fill: '#075173',
                stroke: '#075173',
                lineWidth: 2,
                shadowBlur: 15,
                shadowOffsetX: 0,
                shadowOffsetY: -4,
                shadowColor: '#13E6FF',
            },
            shape: {
                x1: height1.value * 0.57,
                y1: 0,
                x2: 0,
                y2: 0,
            },
            left: 'center',
            bottom: '21%',
            silent: true,
        },
        {
            type: 'line',
            z: 4,
            style: {
                fill: '#075173',
                stroke: '#075173',
                lineWidth: 2,
                shadowBlur: 15,
                shadowOffsetX: 0,
                shadowOffsetY: -4,
                shadowColor: '#13E6FF',
            },
            shape: {
                x1: height1.value * 0.43,
                y1: 0,
                x2: 0,
                y2: 0,
            },
            left: 'center',
            bottom: '28.5%',
            silent: true,
        },
    ],
},

};
`

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值