156 lines
3.8 KiB
JavaScript
156 lines
3.8 KiB
JavaScript
import echarts from 'echarts/lib/echarts';
|
|
import { hdyjColor } from '../../../../utils/renutils';
|
|
|
|
export default function rzOption({ data, skinfo }) {
|
|
const serialData = data.map(obj => [obj.tm, obj.rz || obj.z || 0]);
|
|
|
|
let sorted = serialData.map(o => o[1]);
|
|
const markLine = {};
|
|
if (skinfo && typeof skinfo.damel === 'number' && typeof skinfo.ddz === 'number' && typeof skinfo.fsltdz === 'number') {
|
|
const { damel, fsltdz, ddz } = skinfo;
|
|
sorted.push(damel + 0.5);
|
|
sorted.push(fsltdz);
|
|
sorted.push(ddz - 0.5);
|
|
|
|
markLine.data = [
|
|
{ yAxis: fsltdz, label: { formatter: '汛限水位' }, lineStyle: { color: 'red' } },
|
|
{ yAxis: ddz, label: { formatter: '死水位' } },
|
|
{ yAxis: damel, label: { formatter: '坝顶高程' } },
|
|
];
|
|
} else if (data[0]) {
|
|
const { sfz, wrz, grz } = data[0];
|
|
markLine.data = [];
|
|
if (sfz) {
|
|
sorted.push(sfz)
|
|
markLine.data.push({ label: { formatter: '设防水位' }, yAxis: sfz, lineStyle: { color: hdyjColor[1] } });
|
|
}
|
|
if (wrz) {
|
|
sorted.push(wrz)
|
|
markLine.data.push({ label: { formatter: '警戒水位' }, yAxis: wrz, lineStyle: { color: hdyjColor[2] } });
|
|
}
|
|
if (grz) {
|
|
sorted.push(grz)
|
|
markLine.data.push({ label: { formatter: '保证水位' }, yAxis: grz, lineStyle: { color: hdyjColor[3] } });
|
|
}
|
|
}
|
|
|
|
sorted = sorted.sort()
|
|
let maxVal = sorted[0] || 0;
|
|
let minVal = sorted[sorted.length - 1] || 0;
|
|
let dz = 0.5;
|
|
maxVal = Math.ceil(maxVal / dz) * dz + 0.1;
|
|
minVal = Math.floor(minVal / dz) * dz - 0.1;
|
|
|
|
return {
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
lineStyle: {
|
|
color: '#fff'
|
|
}
|
|
}
|
|
},
|
|
grid: {
|
|
x: 24,
|
|
y: 24,
|
|
x2: 38,
|
|
y2: 42,
|
|
borderWidth: 0
|
|
},
|
|
calculable: true,
|
|
xAxis: [
|
|
{
|
|
type: 'time',
|
|
splitLine: {
|
|
show: false
|
|
},
|
|
axisLabel: {
|
|
color: '#bbb',
|
|
fontSize: 9,
|
|
textShadowBlur: 4,
|
|
textShadowColor: '#6ab',
|
|
// formatter: val => val.substr('2020-10-14 '.length, 2)
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: '#07a6ff',
|
|
width: 0.5,
|
|
}
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
}
|
|
}
|
|
],
|
|
yAxis: [
|
|
{
|
|
type: 'value',
|
|
position: 'right',
|
|
splitLine: {
|
|
show: true,
|
|
lineStyle: {
|
|
color: '#07a6ff',
|
|
width: 0.25,
|
|
type: 'dashed'
|
|
}
|
|
},
|
|
axisLabel: {
|
|
color: '#bbb',
|
|
fontSize: 10,
|
|
textShadowBlur: 4,
|
|
textShadowColor: '#6ab',
|
|
},
|
|
axisLine: {
|
|
show: false
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
min: minVal,
|
|
max: maxVal
|
|
}
|
|
],
|
|
series: [
|
|
{
|
|
name: '水位',
|
|
type: 'line',
|
|
showSymbol: false,
|
|
label: {
|
|
show: false,
|
|
},
|
|
data: serialData,
|
|
lineStyle: {
|
|
normal: {
|
|
width: 1,
|
|
}
|
|
},
|
|
areaStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
offset: 0,
|
|
color: 'rgba(3, 194, 236, 0.3)'
|
|
}, {
|
|
offset: 0.8,
|
|
color: 'rgba(3, 194, 236, 0)'
|
|
}
|
|
], false),
|
|
shadowColor: 'rgba(0, 0, 0, 0.1)',
|
|
shadowBlur: 10
|
|
}
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
color: '#03C2EC'
|
|
}
|
|
},
|
|
markPoint: {
|
|
data: [
|
|
{ type: 'max', name: '最大值', symbol: 'circle', symbolSize: 1, symbolOffset: [0, -12] },
|
|
{ type: 'min', name: '最小值', symbol: 'circle', symbolSize: 1, symbolOffset: [0, 12] }
|
|
]
|
|
},
|
|
markLine,
|
|
}
|
|
]
|
|
};
|
|
} |