echartsConfig.js 8.06 KB
var dianLiangOne = {
    tooltip: {
        show: false,
    },
    grid: {
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        // borderColor: '#000',
        // borderWidth: 1,
    },
    xAxis: {
        type: 'value',
        axisLabel: {
            show: false,
        },
        splitLine: {
            show: false,
        },
        axisLine: {
            show: false,
        },
        axisTick: {
            show: false,
        },
        splitArea: {
            show: false,
        },
    },
    yAxis: {
        type: 'category',
        axisLabel: {
            show: false,
        },
        data: [],
        axisLine: {
            show: false,
        },
        axisTick: {
            show: false,
        },
    },
    series: [
        {
            //For shadow, 解决最大值接近整数时label被截断的问题
            type: 'pictorialBar',
            symbol: 'roundRect',
            symbolRepeat: 'fixed',
            // symbolClip: true,
            symbolSize: [4, 10],
            symbolMargin: 3,
            symbolBoundingData: 100,
            barWidth: '50%',
            itemStyle: {
                normal: {
                    color: '#2d3b46',
                },
            },
            label: {
                show: false,
            },
            data: [100],
            animation: false,
            z: 1,
        },
        {
            name: 'lalal',
            type: 'pictorialBar',
            symbol: 'roundRect',
            symbolRepeat: true,
            symbolSize: [4, 10],
            symbolMargin: 3,
            symbolBoundingData: 100,
            barWidth: '50%',
            label: {
                show: false,
            },
            data: [100],
            itemStyle: {
                normal: {
                    color: function (params) {
                        return params.data < 20 ? '#ff0000' : '#42ecb2';
                    },
                },
            },
            z: 2,
        },
    ],
}

var warehouseHealthLineOption = {
    color: ['#04efcd', '#fdb300', '#f43d33'],
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross',
            label: {
                backgroundColor: '#6a7985'
            }
        }
    },
    grid: {
        top: '5%',
        left: '0.5%',
        right: '1%',
        bottom: '2%',
        containLabel: true,
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        axisLabel: {
            textStyle: {
                color: '#fff',
            },
        },
        data: []
    },
    yAxis: {
        type: 'value',
        min: 0, //最小百分比
        max: 100, //最大百分比
        axisLabel: {
            interval: 'auto',
            formatter: '{value}%', //y轴数值,带百分号
            textStyle: {
                color: '#fff',
            },
        },
    },
    series: [
        {
            name: '运行',
            data: [],
            type: 'line',
            stack: 'Total',
            symbolSize: 7,
            areaStyle: {}
        },
        {
            name: '待机',
            data: [],
            type: 'line',
            stack: 'Total',
            symbolSize: 7,
            areaStyle: {}
        },
        {
            name: '故障',
            data: [],
            type: 'line',
            stack: 'Total',
            symbol: function (value, params) {
                // value 是当前数据值,params 是数据项信息
                return value === 0 ? 'none' : 'circle';
            },
            symbolSize: 7,
            areaStyle: {}
        }
    ]
}

var warehouseHealthOption = {
    color: ['#04efcd', '#fdb300', '#f43d33'],
    tooltip: {
        trigger: 'axis',
        // 鼠标放上去显示百分比
        // formatter: '{c}%',
        formatter: function (params) {
            var result = params[0].name + '<br>';
            params.forEach(function (item) {
                if (item.value) {
                    result += item.marker + '  ' + item.value + '%</br>';
                } else {
                    result += item.marker + '   - </br>';
                }
            });
            return result;
        },
        axisPointer: {
            // Use axis to trigger tooltip
            type: 'shadow', // 'shadow' as default; can also be 'line' or 'shadow'
        },
    },
    legend: {},
    grid: {
        top: '13%',
        left: '0.5%',
        right: '3%',
        bottom: '2%',
        containLabel: true,
    },
    xAxis: {
        type: 'category',
        axisLabel: {
            rotate: 0, // 角度值:Number
            interval: -1,
            // fontSize: 18, // 顺便调小一点字体大小
            textStyle: {
                color: '#fff',
            },
        },
        axisLine: {
            lineStyle: {
                color: '#afa3a3', // X轴线的颜色
                width: 1, // x轴线的宽度
            },
        },
        data: [],
    },

    yAxis: {
        type: 'value',
        min: 0, //最小百分比
        max: 100, //最大百分比
        splitLine: true,
        axisTick: {
            show: true,
            alignWithLabel: true,
        },
        axisLabel: {
            // fontSize: 8,
            show: true,
            interval: 'auto',
            formatter: '{value}%', //y轴数值,带百分号
            textStyle: {
                color: '#fff',
            },
        },

        axisLine: {
            lineStyle: {
                color: '#afa3a3', // y轴线的颜色
                width: 1, // y轴线的宽度
            },
        },
    },

    series: [
        {
            type: 'bar',
            barMaxWidth: '50',
            stack: 'Ad',
            emphasis: {
                focus: 'series',
            },
            itemStyle: {
                normal: {
                    label: {
                        show: false, //开启显示数值
                        formatter: function (params) {
                            //标签内容
                            return params.value + '%';
                        },
                        // position: 'top', //数值在上方显示
                        textStyle: {
                            //数值样式
                            color: '#ffff', //字体颜色
                            // fontSize: 15, //字体大小
                        },
                    },
                },
            },
            data: [],
        },
        {
            type: 'bar',
            stack: 'Ad',
            emphasis: {
                focus: 'series',
            },
            itemStyle: {
                normal: {
                    label: {
                        show: false, //开启显示数值
                        formatter: function (params) {
                            //标签内容
                            return params.value + '%';
                        },
                        // position: 'top', //数值在上方显示
                        textStyle: {
                            //数值样式
                            color: '#ffff', //字体颜色
                            // fontSize: 15, //字体大小
                        },
                    },
                },
            },
            data: [],
        },
        {
            type: 'bar',
            stack: 'Ad',
            emphasis: {
                focus: 'series',
            },
            itemStyle: {
                normal: {
                    label: {
                        show: true, //开启显示数值
                        formatter: function (params) {
                            //标签内容
                            return params.value + '%';
                        },
                        position: 'top', //数值在上方显示
                        textStyle: {
                            //数值样式
                            color: '#ffff', //字体颜色
                            // fontSize: 15, //字体大小
                        },
                    },
                },
            },
            data: [],
        },
    ],
};