Pre loader

Cleaning up SciChartVerticalGroup

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

Looking into https://www.scichart.com/documentation/js/current/typedoc/classes/scichartverticalgroup.html I see I can add surfaces to the group, but what about removing them?

I’ve constructed a problematic codepen to show a potential issue:
https://codepen.io/jrfv/full/JjwraLK

Any reason for not being able to remove surfaces from the group?

Thanks!

Version
3.2.442
  • You must to post comments
Best Answer
0
0

So for reference. Now SciChartVerticalGroup has a method for removing a surface subscription.

verticalGroup.removeSurface(sciChartSurface)

Also, notice that it is called internally when the surface is being deleted.

  • You must to post comments
0
0

Hello, we are working on a proper fix.
Meanwhile, try using a workaround by adding

verticalGroup.layoutManagers.pop()

when removing a chart.

  • You must to post comments
0
0

Wouldn’t that possibly leave groupLeftSize and groupRightSize with wrong values?

I’m using my own makeshift class for now:

class VerticalAlignedGroup extends SciChartVerticalGroup {
  removeSurfaceFromGroup(surface) {
    const idx = this.layoutManagers.findIndex(
      (l) => l.sciChartSurface.id === surface.id
    );
    if (idx !== -1) {
      const synchronisedLayoutManager = this.layoutManagers[idx];
      this.layoutManagers.splice(idx, 1);
      // might get away with a custom object with mocked functions, as this 
      // won't contribute to actual layout, and should be GC'ed soon
      synchronisedLayoutManager.verticalGroup = new SciChartVerticalGroup();
      this.onLeftSizeChanged(synchronisedLayoutManager.id, 0);
      this.onRightSizeChanged(synchronisedLayoutManager.id, 0);
      this.synchronizeAxisSizes();
    }
  }
}
  • Jim Risen
    Right, that will not reset the layout sizes on other surfaces of the chart. So you need a way to recalculate them. Your approach looks good.
  • Andrew Burnett-Thompson
    Update for both Jim & Joao. Did we add a function into SciChartVerticalGroup to remove a chart? And if so have we released?
  • João Velasques
    I do notice it is present already in version 3.2.481. Upgrading today!
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.