echarts的折线图上添加标准线

主要字段markLine

var myChart = echarts.init(document.getElementById('main'));  
var option = {  
    title: {  
        text: '折线图示例'  
    },  
    tooltip: {  
        trigger: 'axis'  
    },  
    xAxis: {  
        type: 'category',  
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']  
    },  
    yAxis: {  
        type: 'value'  
    },  
    series: [  
        {  
            name: '数据',  
            type: 'line',  
            data: [120, 132, 101, 134, 90, 230, 210],  
            markLine: {  
                data: [  
                    {  
                        yAxis: 150, // 第一条标准线的Y轴位置  
                        name: '上界标准线', // 线的名称  
                        lineStyle: {  
                            color: 'red', // 线的颜色  
                            type: 'solid', // 线型为实线  
                            width: 2 // 线的宽度  
                        },  
                        label: {  
                            show: true, // 显示标签  
                            position: 'end', // 标签的位置在线的末端  
                            formatter: '{b}: {c}' // 标签的格式  
                        }  
                    },  
                    {  
                        yAxis: 100, // 第二条标准线的Y轴位置  
                        name: '下界标准线', // 线的名称  
                        lineStyle: {  
                            color: 'blue', // 线的颜色  
                            type: 'dashed', // 线型为虚线  
                            width: 2 // 线的宽度  
                        },  
                        label: {  
                            show: true, // 显示标签  
                            position: 'start', // 标签的位置在线的起始端  
                            formatter: '{b}: {c}' // 标签的格式  
                        }  
                    }  
                ]  
            }  
        }  
    ]  
};  
  
myChart.setOption(option);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值