设置基准线
显示一条与y轴平行的线
var option = {
title: {
// text: 'Summary By Personnel'
},
// visualMap: {
// show: true,
// pieces: [{
// gt: 0,
// lte: 3, //这儿设置基线上下颜色区分 基线下面为绿色
// color: '#03d6d6'
// }, {
// gt: 3, //这儿设置基线上下颜色区分 基线上面为红色
// color: '#e91642'
// }]
// },
legend: {
// Try 'horizontal'
// orient: 'vertical',
right: 10,
top: '10px',
data: legendData //
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
dataset: {
source: dataSource//显示的数据,[[name,val,val],[name,val,val]]
},
xAxis: {
type: 'category',
axisLabel: {
interval: -30,
rotate: 30, //倾斜的程度
}
},
yAxis: {
type: 'value'
},
series: []
};
//*重点
//显示与y轴平行的线
legendData.filter((item, index) => {/循环
option.series.push({
name: item,
type: 'line',
// barWidth: 15,
label: {
show: true,
position: 'top',
},
markLine: {
symbol: ['none', 'none'], //去掉箭头
silent: true,
lineStyle: {
normal: {
type: 'solid',//直线
color: '#ff0000' // 这儿设置安全基线颜色
}
},
data: [
{
yAxis: markprice,
},
],
label: {
show: true,
//position: 'insideStartBottom',
color: 'rgb(91, 155, 213)',
normal: {
ormatter: 'insideStartBottom' ,// 这儿设置安全基线 显示的内容 insideStartBottom表示显示基准线的大小,可以自定义
}
},
}
})
});