apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.54k stars 19.61k forks source link

[Bug] echartsInstance. appendData 这个API加载进去的数据,我想数据达到一定数量去清空掉,但是似乎没有办法清除曲线数据,内存一直在涨 #20318

Open jipolun opened 1 month ago

jipolun commented 1 month ago

Version

5.5.1

Link to Minimal Reproduction

none

Steps to Reproduce

`

` 是这样的,我需要绘制40条曲线,每条曲线上有很多个点(大概每50ms,产生250个点),于是我就看文档使用echart的appendData API,在一个C# signalR的槽函数里面接收数据,然后送到echart里面去渲染。 因为数据量很大,所以我在判断当一条曲线的数据量到达5000个的时候,就把这些曲线全部清空,进行重新绘制,但是我在echarts官网的文档里面没有找到类似"removeData"或者“shiftData”的API,于是我就使用以下办法来清空数据(因为业务需要,我们使用 clear或者disopse来销毁组件,我只是想把数据清除掉) ` if( Chart_Tmp.chart.getOption().series[0].data.length>5000) { let myseries:any[]=[]; for(let i=0;i<40;i++) { myseries.push({ data: [] }) } Chart_Tmp.chart.setOption({ series: myseries }); //Chart_Tmp.chart.clear(); }` 然后打开网页,看到echart的数据确实被清除了,能达到预期的结果,但是同时发现内存在不断的涨 微信图片_20240904160438 ### Current Behavior 我的数据格式[ ["0",10], ["1",12], ["2",13], ["3",10], ["4",15], ["5",10], ..... ] ### Expected Behavior 理论上应该清空掉了,就不应该会再涨起来 ### Environment ```markdown - OS:windows11 - Browser:chrome - Framework:vue3 +Typescript ``` ### Any additional comments? _No response_
echarts-bot[bot] commented 1 month ago

@jipolun It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED
**TITLE** [Bug] echartsInstance. appendData API loads the data, I want the data to reach a certain amount to clear, but there seems to be no way to clear the curve data, the memory keeps rising
Ovilia commented 1 month ago

As its name suggests, appendData concatenates the data and do not remove old ones. You can manage the logic of data by yourself and call setOption with the new data.

jipolun commented 1 month ago

As its name suggests, appendData concatenates the data and do not remove old ones. You can manage the logic of data by yourself and call setOption with the new data.

但是我的数据量很大,40条曲线,每50ms250个 一秒会产生20万个点,我怕setOption 效率太低,所以才使用的appendData