Pre loader

Deleted series stays in legend

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

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.

Version
^3.2.516
  • You must to post comments
Best Answer
0
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.