|
|
@ -1,12 +1,25 @@ |
|
|
|
<template> |
|
|
|
<el-card class="box-card"> |
|
|
|
<el-empty v-if="noData" description="暂无数据"></el-empty> |
|
|
|
|
|
|
|
<el-radio-group |
|
|
|
v-show="!noData" |
|
|
|
v-model="electricYType" |
|
|
|
class="float-right -m-1" |
|
|
|
size="small" |
|
|
|
style="position: relative; z-index: 999" |
|
|
|
@change="$emit('on-y-type-change', electricYType)" |
|
|
|
> |
|
|
|
<el-radio-button label="line">线性</el-radio-button> |
|
|
|
<el-radio-button label="log">对数</el-radio-button> |
|
|
|
</el-radio-group> |
|
|
|
|
|
|
|
<div id="realtimeContainer"></div> |
|
|
|
</el-card> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { computed, defineExpose, defineProps, onMounted, ref, watchEffect } from 'vue'; |
|
|
|
import { computed, defineExpose, defineProps, defineEmits, onMounted, ref, watchEffect } from 'vue'; |
|
|
|
import { useStore } from 'vuex'; |
|
|
|
import * as echarts from 'echarts/core'; |
|
|
|
import { DataZoomComponent, GridComponent, LegendComponent, ToolboxComponent, TooltipComponent } from 'echarts/components'; |
|
|
@ -26,6 +39,8 @@ echarts.use([ |
|
|
|
DataZoomComponent, |
|
|
|
]); |
|
|
|
|
|
|
|
defineEmits(['on-y-type-change']); |
|
|
|
|
|
|
|
const store = useStore(); |
|
|
|
const props = defineProps({ searchHeight: Number }); |
|
|
|
const realtimeData = computed(() => store.state.statistics.realtimeData); |
|
|
@ -33,6 +48,7 @@ const defaultSelectedLegend = computed(() => store.state.statistics.defaultSelec |
|
|
|
const isMounted = ref(false); |
|
|
|
const noData = ref(true); |
|
|
|
let myChart = null; |
|
|
|
const electricYType = ref('line'); // 电流Y轴类型 line线型 log对数型 |
|
|
|
|
|
|
|
// 设置图表 |
|
|
|
onMounted(() => { |
|
|
@ -55,7 +71,7 @@ function initChart(data) { |
|
|
|
const chartDom = document.getElementById('realtimeContainer'); |
|
|
|
const canvasHeight = document.documentElement.clientHeight - props.searchHeight - 150; |
|
|
|
chartDom.style.height = `${canvasHeight}px`; |
|
|
|
myChart && myChart.dispose(); |
|
|
|
// myChart && myChart.dispose(); |
|
|
|
myChart = echarts.init(chartDom); |
|
|
|
render(data, defaultSelectedLegend.value); |
|
|
|
|
|
|
|