Showing
1 changed file
with
8 additions
and
2 deletions
... | ... | @@ -43,6 +43,12 @@ const handleHistoryData = (message: SubscriptionData, attr: string) => { |
43 | 43 | } as EChartsOption) |
44 | 44 | } |
45 | 45 | |
46 | +function sliceData(data: any[], maxLength = 20) { | |
47 | + if (data.length > maxLength) | |
48 | + return data.slice(1) | |
49 | + return data | |
50 | +} | |
51 | + | |
46 | 52 | const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { |
47 | 53 | const { ts, latestValue } = useLatestMessageValue(message, attr) |
48 | 54 | const option = unref(chartInstance)?.getOption() as EChartsOption |
... | ... | @@ -51,8 +57,8 @@ const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { |
51 | 57 | xAxisData.push(formatToDateTime(ts)) |
52 | 58 | seriesData.push(latestValue) |
53 | 59 | unref(chartInstance)?.setOption({ |
54 | - xAxis: { data: xAxisData }, | |
55 | - series: { data: seriesData }, | |
60 | + xAxis: { data: sliceData(xAxisData) }, | |
61 | + series: { data: sliceData(seriesData) }, | |
56 | 62 | } as EChartsOption) |
57 | 63 | } |
58 | 64 | ... | ... |