Showing
1 changed file
with
8 additions
and
2 deletions
| @@ -43,6 +43,12 @@ const handleHistoryData = (message: SubscriptionData, attr: string) => { | @@ -43,6 +43,12 @@ const handleHistoryData = (message: SubscriptionData, attr: string) => { | ||
| 43 | } as EChartsOption) | 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 | const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { | 52 | const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { |
| 47 | const { ts, latestValue } = useLatestMessageValue(message, attr) | 53 | const { ts, latestValue } = useLatestMessageValue(message, attr) |
| 48 | const option = unref(chartInstance)?.getOption() as EChartsOption | 54 | const option = unref(chartInstance)?.getOption() as EChartsOption |
| @@ -51,8 +57,8 @@ const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { | @@ -51,8 +57,8 @@ const handlerTimeSeriesData = (message: SubscriptionData, attr: string) => { | ||
| 51 | xAxisData.push(formatToDateTime(ts)) | 57 | xAxisData.push(formatToDateTime(ts)) |
| 52 | seriesData.push(latestValue) | 58 | seriesData.push(latestValue) |
| 53 | unref(chartInstance)?.setOption({ | 59 | unref(chartInstance)?.setOption({ |
| 54 | - xAxis: { data: xAxisData }, | ||
| 55 | - series: { data: seriesData }, | 60 | + xAxis: { data: sliceData(xAxisData) }, |
| 61 | + series: { data: sliceData(seriesData) }, | ||
| 56 | } as EChartsOption) | 62 | } as EChartsOption) |
| 57 | } | 63 | } |
| 58 | 64 |