1
|
1
|
<script lang="ts" setup>
|
2
|
2
|
import { computed, onMounted, onUnmounted, ref, unref } from 'vue'
|
3
|
|
-import type { DatasetComponentOption, ECharts, EChartsOption, SeriesOption, XAXisComponentOption } from 'echarts'
|
|
3
|
+import type { DatasetComponentOption, ECharts, EChartsOption } from 'echarts'
|
4
|
4
|
import { init } from 'echarts'
|
5
|
5
|
import { getDefaultOption } from './index.config'
|
6
|
6
|
import type { CreateComponentType, RenderComponentExposeType } from '@/core/Library/types'
|
...
|
...
|
@@ -56,16 +56,11 @@ const handlerTimeSeriesData = (commandSource: CommandSource, message: Subscripti |
56
|
56
|
const { deviceName } = deviceInfo || {}
|
57
|
57
|
const { ts, latestValue } = useLatestMessageValue(message, attr)
|
58
|
58
|
const option = unref(chartInstance)?.getOption() as EChartsOption
|
59
|
|
- const oldDataset = (option.dataset as DatasetComponentOption[])?.[0].source
|
60
|
|
- // const xAxisData = ((option.xAxis as XAXisComponentOption[])?.[0] as { data: string[] }).data
|
61
|
|
- // const seriesData = ((option.series as SeriesOption[])?.[0].data) as SeriesOption[]
|
62
|
|
- // console.log(option)
|
63
|
|
- // oldDataset.
|
64
|
|
- // xAxisData.push(formatToDateTime(ts))
|
65
|
|
- // seriesData.push({
|
66
|
|
- // name: attrInfo.name,
|
67
|
|
- // data: [],
|
68
|
|
- // })
|
|
59
|
+ const oldDataset = (option.dataset as DatasetComponentOption[])?.[0].source as Recordable[]
|
|
60
|
+ oldDataset.push({
|
|
61
|
+ ts: formatToDateTime(ts),
|
|
62
|
+ [attr]: latestValue,
|
|
63
|
+ })
|
69
|
64
|
|
70
|
65
|
unref(chartInstance)?.setOption({
|
71
|
66
|
title: {
|
...
|
...
|
@@ -73,15 +68,8 @@ const handlerTimeSeriesData = (commandSource: CommandSource, message: Subscripti |
73
|
68
|
},
|
74
|
69
|
dataset: {
|
75
|
70
|
dimensions: ['ts', attr],
|
76
|
|
- source: [
|
77
|
|
- { ts, [attr]: latestValue },
|
78
|
|
- ],
|
|
71
|
+ source: sliceData(oldDataset),
|
79
|
72
|
},
|
80
|
|
- // legend: {
|
81
|
|
- // data: [attrInfo.name],
|
82
|
|
- // },
|
83
|
|
- // xAxis: { data: sliceData(xAxisData) },
|
84
|
|
- // series: { data: sliceData(seriesData) },
|
85
|
73
|
} as EChartsOption)
|
86
|
74
|
}
|
87
|
75
|
|
...
|
...
|
|