Files
admin-vben5/apps/web-antd/src/views/property/energyManagement/waterPower/waterTrend/index.vue

223 lines
5.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import dayjs from 'dayjs'
import type { Dayjs } from 'dayjs'
import * as echarts from 'echarts'
import { onMounted, ref } from "vue"
import { Page } from '@vben/common-ui'
import { DatePicker } from 'ant-design-vue'
import FloorTree from "../components/floor-tree.vue"
const currentMonth = ref<Dayjs>(dayjs())
const currentYear = ref<Dayjs>(dayjs())
const disabledMonth = (current: Dayjs) => {
return current && current > dayjs().endOf('month')
}
const disabledYear = (current: Dayjs) => {
return current && current > dayjs().endOf('year')
}
onMounted(() => {
//month
const chartMonth = document.getElementById('month')
const myChartMonth = echarts.init(chartMonth)
const optionMonth = {
tooltip: {
trigger: 'axis'
},
legend: {
data: ['当月', '上月']
},
toolbox: {
show: true,
feature: {
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
}
},
calculable: true,
xAxis: [
{
type: 'category',
name: '日',
data: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
}
],
yAxis: [
{
type: 'value',
name: 't'
}
],
series: [
{
name: '当月',
type: 'bar',
data: [
2.0, 4.9, 7.0, 23.2, 25.6, 0.0, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3, 2.0, 0.0, 7.0, 23.2, 0.0, 76.7, 135.6, 162.2, 32.6, 0.0, 6.4, 3.3, 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6
],
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
},
{
name: '上月',
type: 'bar',
data: [
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 0.0, 48.7, 18.8, 6.0, 2.3, 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 0.0, 32.6, 20.0, 6.4, 3.3, 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6
],
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
}
],
dataZoom: [
{
type: 'inside',
xAxisIndex: 0,
zoomOnMouseWheel: true,
filterMode: 'filter',
},
],
}
optionMonth && myChartMonth.setOption(optionMonth)
//year
const chartYear = document.getElementById('year')
const myChartYear = echarts.init(chartYear)
const optionYear = {
tooltip: {
trigger: 'axis'
},
legend: {
data: ['当年', '去年']
},
toolbox: {
show: true,
feature: {
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
}
},
calculable: true,
xAxis: [
{
type: 'category',
name: '月',
data: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
}
],
yAxis: [
{
type: 'value',
name: 't'
}
],
series: [
{
name: '当年',
type: 'bar',
data: [
2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
],
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
},
{
name: '去年',
type: 'bar',
data: [
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
],
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
}
],
dataZoom: [
{
type: 'inside',
xAxisIndex: 0,
zoomOnMouseWheel: true,
filterMode: 'filter',
},
],
}
optionYear && myChartYear.setOption(optionYear)
// 鼠标悬停时激活缩放
myChartYear.on('mouseover', { seriesIndex: 0 }, () => {
myChartYear.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
dataZoomSelectActive: true,
})
})
// 鼠标离开时取消缩放
myChartYear.on('mouseout', { seriesIndex: 0 }, () => {
myChartYear.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
dataZoomSelectActive: false,
})
})
// 鼠标悬停时激活缩放
myChartMonth.on('mouseover', { seriesIndex: 0 }, () => {
myChartMonth.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
dataZoomSelectActive: true,
})
})
// 鼠标离开时取消缩放
myChartMonth.on('mouseout', { seriesIndex: 0 }, () => {
myChartMonth.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect',
dataZoomSelectActive: false,
})
})
})
</script>
<template>
<Page :auto-content-height="true">
<div class="flex h-full gap-[8px]">
<FloorTree class="w-[260px]"></FloorTree>
<div class="flex-1 overflow-hidden">
<div style="background: #fff;border-radius: 8px;padding: 10px;height: 50%;">
<div>
<div style="display: flex;justify-content: space-between;">
<DatePicker v-model:value="currentMonth" :disabled-date="disabledMonth" picker="month" />当月能耗总值30.00t
</div>
</div>
<div id="month" style="height: 100%;width: 100%;"></div>
</div>
<div style="background: #fff;border-radius: 8px;padding: 10px;margin-top: 16px;height: 50%;">
<div>
<div style="display: flex;justify-content: space-between;">
<DatePicker v-model:value="currentYear" :disabled-date="disabledYear" picker="year" />当年能耗总值59.00t
</div>
</div>
<div id="year" style="height: 100%;width: 100%;"></div>
</div>
</div>
</div>
</Page>
</template>