Hi!
As described in Deleting DataSeries Memory, deleting a series with all its data can be done by calling .delete() on the renderable (example 3) .
If i do just that, the legend doesn’t reflect that. Is there something else to do?
See repro based on Chart Legends Example – just added a 2s timeout after initialization that deletes the renderableSeries of data3. Removes the series from the chart but not from the legend.
- Sebastian Goth asked 9 months ago
- You must login to post comments
Hi Sebastian
You are right, calling renderableSeries.delete()
or dataSeries.delete()
does in fact delete the memory associated with that series, but it doesn’t remove it from the chart.
Try this: this code is the correct way to remove a series from the chart and legend, and also delete the memory
// Create the series
const lineSeries = new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, {
xValues: data3.xValues,
yValues: data3.yValues,
dataSeriesName: "Fourth Line Series"
}),
strokeThickness: 3,
stroke: "auto"
});
// Add the series
sciChartSurface.renderableSeries.add(lineSeries);
// Remove the series
sciChartSurface.renderableSeries.remove(lineSeries);
// Also valid for removal - by index
sciChartSurface.renderableSeries.removeAt(0);
// Delete the series memory
lineSeries.delete();
lineSeries = undefined; // only required if not const
// Also valid when removing, you can do remove & delete in one step with this:
// Remove and delete the series.
const deleteOnRemove = true;
sciChartSurface.renderableSeries.remove(lineSeries, deleteOnRemove);
// Also valid to remove & delete - by index
sciChartSurface.renderableSeries.removeAt(0, deleteOnRemove);\
In the case of your repro, you only need one line of code changed, on line 160, change this
setTimeout(() => data3Series.delete(), 2000);
for this
setTimeout(() => sciChartSurface.renderableSeries.remove(data3Series, true), 2000);
Let me know if this helps
Best regards
Andrew
- Andrew Burnett-Thompson answered 9 months ago
- last edited 9 months ago
- You must login to post comments
Please login first to submit.