echartsConfig.js 2.13 KB
var dianLiangOne = {
    // 标题(可选,可删除)
    title: {
        text: '',
        left: 'center',
        textStyle: {
            color: '#ffffff', // 标题文字白色
        },
    },
    // 提示框
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow',
        },
        textStyle: {
            fontSize: 14,
        },
    },
    grid: {
        top: '13%',
        left: '0.5%',
        right: '3%',
        bottom: '15%',
        containLabel: true,
    },
    // 坐标轴
    xAxis: {
        type: 'category',
        data: ['运行', '待机', '故障'], // X轴分类
        axisLine: {
            lineStyle: {
                color: '#ffffff', // X轴线白色
            },
        },
        axisLabel: {
            color: '#ffffff', // X轴文字白色
            fontSize: 14,
        },
    },
    yAxis: {
        type: 'value',
        max: 100, // Y轴最大值100(百分比)
        axisLine: {
            lineStyle: {
                color: '#ffffff', // Y轴线白色
            },
        },
        axisLabel: {
            color: '#ffffff', // Y轴文字白色
            fontSize: 14,
            formatter: '{value}%', // 显示百分比
        },
        splitLine: {
            show: false,
            lineStyle: {
                color: 'rgba(255,255,255,0.2)', // 网格线半透明白色
            },
        },
    },
    // 系列数据
    series: [
        {
            name: '状态占比',
            type: 'bar',
            barWidth: '40%', // 柱子宽度
            data: [
                { value: 57, itemStyle: { color: '#00e068' } }, // 运行:绿色
                { value: 40, itemStyle: { color: '#ffb800' } }, // 待机:橙色
                { value: 3, itemStyle: { color: '#ff3333' } }, // 故障:红色
            ],
            // 柱子上显示数值(百分比)
            label: {
                show: true,
                position: 'top', // 数值显示在柱子顶部
                color: '#ffffff', // 数值文字白色
                fontSize: 14,
                formatter: '{c}%',
            },
        },
    ],
}