import echarts from 'echarts/lib/echarts'; import { sw } from './mock' export default function DrpOption(data = sw) { const maxVal = Math.max(...data.map(obj => obj.drp)) let eopts = { tooltip: { trigger: 'axis', }, grid: { top: "15%", left: "10%", right: "10%", bottom: "15%" }, legend: { show: true, data: ['降雨量'], left: 'center', top: 0, itemWidth: 10, padding: 0 }, 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: '降雨量(mm)', splitLine: { show: true, lineStyle: { color: '#07a6ff', width: 0.25, type: 'dotted' } }, axisLabel: { color: '#333', fontSize: 10 }, axisLine: { show: true, lineStyle: { color: '#07a6ff', width: 0.5 } }, axisTick: { show: true }, min: 0, max: maxVal }, ], } let chartData = { series: [ { name: '降雨量', type: 'bar', barWidth: '60%', data: data.map(o => o.drp).reverse(), itemStyle: { color: '#007AFD' }, label: { show: false } }, ], } return { eopts, chartData } }