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'
}
},
visualMap: {
show: false,
pieces: [
{
gt: 0,
lte: 9, //这儿设置基线上下颜色区分 基线下面为绿色
color: '#ff0000'
},
{
gt: 9,
lte: 12,
//中间部分颜色显示
color: '#00ff00'
},
{
gt: 12, //这儿设置基线上下颜色区分 基线上面为红色
color: '#0000ff'
}
]
},
series: [
{
name: '最高气温',
smooth: true,
type: 'line',
data: [8, 13, 7, 13, 12, 13, 6],
markLine: {
data: [
{ type: 'average', yAxis: 9, name: '平均值' },
{ type: 'average', yAxis: 12, name: '平均值' }
],
label: {
normal: {
formatter: '安全基线' // 这儿设置安全基线
}
}
}
}
]
};