欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

echarts添加多条辅助线(MarkLine)

程序员文章站 2022-05-27 13:44:30
...

先上效果图

echarts添加多条辅助线(MarkLine)

 下面贴option代码

option = {
    title: {
        text: '多条MarkLine实例',
        left: 'center'
    },
    tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b} : {c}'
    },
    legend: {
        left: 'left',
        data: ['2的指数', '3的指数']
    },
    xAxis: {
        type: 'category',
        name: 'x',
        splitLine: {show: false},
        data: ['一', '二', '三', '四', '五', '六', '七', '八', '九']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    yAxis: {
        type: 'log',
        name: 'y',
        minorTick: {
            show: true
        },
        minorSplitLine: {
            show: true
        },
        max:'dataMax',
        min:'dataMin'
        
    },
    series: [
        {
            name: '3的指数',
            type: 'line',
            data: [1, 3, 9, 27, 81, 247, 15, 122, 25]
        },
        {
            name: '2的指数',
            type: 'line',
            data: [1, 2, 4, 8, 16, 32, 64, 128, 256]
        },
        {
            name: '1/2的指数',
            type: 'line',
            data: [1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512],
            
            //实现辅助线部分


            markLine: {
                silent: true,
                data: [{
                    yAxis: 5
                }, {
                    yAxis: 10
                }, {
                    yAxis: 15
                }, {
                    yAxis: 25
                }, {
                    yAxis: 35
                }],
                lineStyle: {
                    normal: {
                    type: 'solid',
                },
            },
                
            }
        }
    ]
};

 

相关标签: echarts