echarts markline如何将两条线颜色分别设置

var option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value'
    },
    series: [{       
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        markLine: {
            itemStyle: {
                normal: { lineStyle: { type: 'solid', color: '#000' }, label: { show: true, position: 'end' } },
            },
            data: [
                {
                    name: '平均线',
                    // 支持 'average', 'min', 'max'
                    type: 'average'
                },
                {
                    name: 'Y 轴值为 100 的水平线',
                    yAxis: 100
                }
            ]
        },
    }]
}

11111

分别设置每条线的颜色:

var option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        markLine: {
            itemStyle: {
                normal: { 
                    lineStyle: {
                        type: 'solid',
                        // 这儿设置的颜色是公共配置,如需单独配置,请在data里配置
                        // color: '#000',
                    }, 
                    label: { 
                        show: true,
                        position: 'end'
                            
                    }
                },
            },
            data: [
                {
                    name: '平均线',
                    type: 'average',
                    // 单独配置每条线的样式
                    lineStyle: {
                        color: 'green'
                    }
                },
                {
                    name: 'Y 轴值为 100 的水平线',
                    yAxis: 100,
                    // 单独配置每条线的样式
                    lineStyle: {
                        color: 'red'
                    }
                }
            ]
        },
    }]
};

1111

 原链接:文章来源

猜你喜欢

转载自blog.csdn.net/weixin_43412413/article/details/101294831