import echarts from 'echarts/lib/echarts'; export default function DrpOption( data, ) { const maxVal = Math.max(...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)) let eopts = { tooltip: { trigger: 'axis', }, grid: { bottom: "8%", left: "10%", right: "8%", width: '80%', height: '80%' }, legend: { // 显示图例 show: false, }, xAxis: [ { type: 'category', data: data.map(o => o.tm.substr("2020-".length,11)), 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, max: maxKr } ], } let chartData = { 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) } ], } return { eopts, chartData } }