echart中画一条虚线
程序员文章站
2022-07-13 08:33:54
...
有个项目需要在echart中画出一条虚线,代码如下:
option = {
title: {
text: '未来一周气温变化',
subtext: '纯属虚构'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['最高气温', '最低气温']
},
toolbox: {
show: true,
feature: {
dataZoom: {
yAxisIndex: 'none'
},
dataView: {readOnly: false},
magicType: {type: ['line', 'bar']},
restore: {},
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} °C'
}
},
series: [
{
name: '最低气温',
type: 'line',
data: [1, -2, 2, 5, 3, 2, 0],
markPoint: {
data: [
{name: '周最低', value: -2, xAxis: 4, yAxis: -1.5}
]
},
markLine: {
data: [
{type: 'average', name: '起点'},
[{
xAxis: 0, yAxis: 1
}, {
label: {
position: 'end',
formatter: '星哥要的值 '
},
xAxis: 6, yAxis:1,
name: '终点'
}]
]
}
}
]
};
一个起点:xAxis: 0, yAxis: 1
一个终点: xAxis: 6, yAxis:1,