主要字段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);