import echarts from 'echarts/lib/echarts' export default function drpOption ({ data, }) { const maxVal = Math.max(...data.map(obj => obj.drp)) // const minVal = Math.min(...data.map(obj => obj.drp)) const maxSw = Math.ceil(Math.max(...data.map(obj => obj.rz))) const minSw = Math.floor(Math.min(...data.map(obj => obj.rz))) const maxKr = Math.max(...data.map(obj => obj.w)) const minKr = Math.min(...data.map(obj => obj.w)) return { tooltip: { trigger: 'axis' }, grid: { top: '18%', left: '5%', right: '5%', width: '90%', height: '70%' }, legend: { // 显示图例 show: true, left:60 }, xAxis: [ { type: 'category', data: data.map(o => o.tm), inverse: true, splitLine: { show: false }, axisLabel: { color: '#333', fontSize: 12, formatter: val => val.substr('2020-'.length, 11) }, axisLine: { lineStyle: { color: '#07a6ff', width: 0.5 } }, axisTick: { show: false } } ], yAxis: [ { type: 'value', position: 'left', name: '水位(m)', splitLine: { show: true, lineStyle: { color: '#07a6ff', width: 0.25, type: 'dotted' } }, axisLabel: { color: '#333', fontSize: 12 }, axisLine: { show: false }, axisTick: { show: false }, min: minSw, max: maxSw }, { type: 'value', position: 'right', name: '库容(万m³)', splitLine: { show: false, lineStyle: { color: '#07a6ff', width: 0.25, type: 'dotted' } }, axisLabel: { color: '#333', fontSize: 12 }, axisLine: { show: false }, axisTick: { show: false }, min: minKr - 0.1, max: maxKr + 0.1 } ], series: [ { yAxisIndex:0, name: '水位', type: 'line', symbol: 'none', color: '#0AE0B5', label: { show: false }, data: data.map(o => o.rz ? o.rz.toFixed(2):null ) }, { yAxisIndex:1, name: '库容', type: 'line', color: '#007AFD', symbol: 'none', showSymbol: false, label: { show: false }, data: data.map(o => o.w) } ] } }