|
|
@@ -6,17 +6,17 @@
|
|
|
:init-options="{ height: 400 }"
|
|
|
autoresize
|
|
|
style="width: 100%; height: 100%"
|
|
|
- v-if="option.dataset.some((item) => item.source.length > 0)"
|
|
|
+ v-show="option.dataset.some((item) => item.source.length > 0)"
|
|
|
/>
|
|
|
|
|
|
- <el-empty :image="emptyImg" v-else>
|
|
|
+ <el-empty :image="emptyImg" v-show="!option.dataset.some((item) => item.source && item.source.length > 0)">
|
|
|
<template v-slot:description> </template>
|
|
|
</el-empty>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
- import { Vue, Component, Prop } from 'vue-property-decorator'
|
|
|
+ import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
|
|
|
import { IStatisticsDayNHour } from '../api/common'
|
|
|
import emptyImg from '@/assets/icon/null.png'
|
|
|
import { IPointTarget } from '../../configuration/api/common'
|
|
|
@@ -26,6 +26,7 @@
|
|
|
@Prop({ type: String }) title!: string
|
|
|
@Prop({ type: Object, default: () => ({}) }) data!: IStatisticsDayNHour
|
|
|
@Prop({ type: Array, default: () => [] }) standards!: IPointTarget['showVos']
|
|
|
+ @Prop({ type: String, default: 'rfallTotal' }) rainfallKey!: string
|
|
|
emptyImg = emptyImg
|
|
|
|
|
|
getCodeName(code) {
|
|
|
@@ -38,29 +39,29 @@
|
|
|
const dataset = [
|
|
|
{
|
|
|
id: 'rainfall',
|
|
|
- source: (rainFallVos || []).filter((item) => !!item.rfallTotal)
|
|
|
+ source: (rainFallVos || []).filter((item) => !!item[this.rainfallKey])
|
|
|
},
|
|
|
...datas.map(({ checkCode, statisticalData }) => ({
|
|
|
id: checkCode,
|
|
|
source: statisticalData
|
|
|
}))
|
|
|
]
|
|
|
- // 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
|
|
|
const series = dataset
|
|
|
.map(({ id }, index) => {
|
|
|
return index === 0
|
|
|
? {
|
|
|
name: '降雨量',
|
|
|
- dimensions: ['xposition', 'rfallTotal'],
|
|
|
+ dimensions: ['xposition', this.rainfallKey],
|
|
|
datasetIndex: index,
|
|
|
type: 'line',
|
|
|
symbol: 'circle',
|
|
|
- smooth: true
|
|
|
+ smooth: true,
|
|
|
+ yAxisIndex: 1
|
|
|
}
|
|
|
: [
|
|
|
- { name: 'minValue', displayName: '最大值' },
|
|
|
- { name: 'maxValue', displayName: '最小值' },
|
|
|
- { name: 'avgValue', displayName: '平均值' }
|
|
|
+ { name: 'maxValue', displayName: '最大值' },
|
|
|
+ { name: 'avgValue', displayName: '平均值' },
|
|
|
+ { name: 'minValue', displayName: '最小值' }
|
|
|
].map((item, typeIndex) => {
|
|
|
return {
|
|
|
name: `${this.getCodeName(id)}-${item.displayName}`,
|
|
|
@@ -68,7 +69,8 @@
|
|
|
datasetIndex: index,
|
|
|
type: 'line',
|
|
|
symbol: { '0': 'emptyCircle', '1': 'rect', '2': 'triangle' }[String(typeIndex)],
|
|
|
- smooth: true
|
|
|
+ smooth: true,
|
|
|
+ yAxisIndex: 0
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -85,21 +87,41 @@
|
|
|
...new Set(
|
|
|
dataset.map((item) => (item.source as { xposition: string }[]).map((item) => item.xposition)).flat()
|
|
|
)
|
|
|
- ].sort((a, b) => (a > b ? 0 : -1))
|
|
|
+ ].sort((a, b) => {
|
|
|
+ const reg = /(?<=\d{4}年)(\d)(?=月)/
|
|
|
+ const left = a.replace(reg, `0$1`)
|
|
|
+ const right = b.replace(reg, `0$1`)
|
|
|
+ return left.localeCompare(right)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ yAxis: [
|
|
|
+ { type: 'value', boundaryGap: false },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ boundaryGap: false,
|
|
|
+ inverse: true,
|
|
|
+ alignTicks: true,
|
|
|
+ position: 'right',
|
|
|
+ name: '降雨量',
|
|
|
+ nameLocation: 'start'
|
|
|
}
|
|
|
],
|
|
|
- yAxis: [{ type: 'value', min: ({ min }) => min }],
|
|
|
dataZoom: dataset.some(({ source }) => source.length > 100) && [
|
|
|
{ type: 'inside', start: 0, end: 100 },
|
|
|
{ start: 0, end: 100 }
|
|
|
],
|
|
|
legend: { show: true, type: 'scroll', width: '80%' },
|
|
|
- grid: { top: 45, left: 45, right: 45, bottom: 30, containLabel: true },
|
|
|
+ grid: { top: 45, left: 45, right: 45, bottom: 45, containLabel: true },
|
|
|
toolbox: { show: true, feature: { restore: { show: true }, saveAsImage: { show: true } } },
|
|
|
dataset,
|
|
|
series
|
|
|
}
|
|
|
}
|
|
|
+ @Watch('option')
|
|
|
+ log(val) {
|
|
|
+ console.log(val)
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|