import echarts from 'echarts/lib/echarts'; import moment from 'moment'; export default function DrpOption(data=[]) { const maxY = Math.max(...data.map(item => item.sumDrp)) let eopts = { tooltip: { trigger: 'axis', }, grid: { x: 18, y: 24, x2: 28, y2: 36, borderWidth: 0, bottom: '10%', left: '8%', width: '90%', }, calculable: true, xAxis: [ { type: 'category', data: data.map(o => moment(o.time).format("HH:mm")), splitLine: { show: false }, axisLabel: { color: '#bbb', fontSize: 14, overflow: 'truncate', }, axisLine: { lineStyle: { color: '#dfdfdf', width: 0.5 } }, axisTick: { show: false } } ], yAxis: [ { type: 'value', position: 'left', splitLine: { show: true, lineStyle: { color: '#07a6ff', width: 0.25, type: 'dashed' } }, axisLabel: { color: '#bbb', fontSize: 10, }, axisLine: { show: false }, axisTick: { show: false }, min: 0, max:maxY } ], // dataZoom: [ // { // type: 'slider', // 设置为滑动条类型 // xAxisIndex: 0, // 指定控制第一个 x 轴 // start: 0, // 初始窗口的起始位置(百分比) // end: 100, // 初始窗口的结束位置(百分比) // } // ], } let chartData = { series: [ { name: '面雨量(mm)', type: 'bar', barWidth: '60%', data: data.map(o => o.sumDrp), itemStyle: { normal: { color: "#6395f9" } } } ] } return { eopts, chartData } }