Closed sknhkrn closed 2 years ago
Or is there any issue with am5 hence the high memory usage?
Please refer to this tutorial which discusses dynamic/inremental data updates: https://www.amcharts.com/docs/v5/concepts/data/#Incremental_updates
Okey, I did some modification to my codes.
But now the problem is, I cannot remove the first data in the series. My charts only display a certain time period of data. For example, the user want to display 1 hour of data in realtime.
Therefore, what I do is I retrieve the latest one hour data and I pushAll the latest data (for example: 3 new data) into the series. However, I also need to remove the same amount of data in the beginning so the chart will keep display the latest one hour.
Is there a way to do that too?
Yes:
series.data.removeIndex(0);
Hi, thanks - it works better now.
Hi, can I ask is there a way to combine the existing data which already set in the series (eg: series.data.setAll(data)) with a new one?
For example, for (let i = 0; i < 5; i++) { let series = chart.series.push(am5xy.LineSeries.new(root, { name: "parameter" + i, xAxis: xAxis, yAxis: yAxis, valueYField: "value", valueXField: "date", legendValueText: "{valueY}", fill: am5.color(colors[i]), stroke: am5.color(colors[i]) })); var dataArray = [{ year: "2019", value: 1200 },{ year: "2020", value: 1750 }{ year: "2021", value: 1555 }];
series.data.setAll(dataArray ); }
So, I already set the data into the series. Next, I want to add and combine new data. However, I do not want to add to the array and setAll again into the series, instead I want to add the new data into the series.
Fyi, the reason I ask this question is because I am using line chart in realtime environment and I am handling thousands of data. Therefore, I need to update the data every a few seconds.
Currently, I combine the new data into the existing data array and create new series each time. However, this causing high memory usage and lag on my application after a few minutes of running.
Therefore, if I can update the data directly on the series, I do not need to create a new series each time I update the data hence to improve performance and remove the high usage of memory.
Thank you. I hope there is a solution for this.