Pre loader

Sync and pan multiple charts

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
0
0

Hi im trying to create a screen with multiple charts (once candle stick the other bar) that are both dynamically updated every second with a new point.

…Ive done that bit.

But when I pan one chart I want it to update the pan position of the other chart
I’ve used the CreateMultiPaneStockChartsFragment as reference to try and do this.

I’ve tried..

            UpdateSuspender.using(sciChartSurface, new Runnable() {
            @Override
            public void run() {
                Collections.addAll(sciChartSurface.getRenderableSeries(), candlestickSeries);
                sciChartSurface.getChartModifiers().add(builder.newModifierGroupWithDefaultModifiers().build());
                sciChartSurface.getChartModifiers().add(builder.newModifierGroup().withMotionEventsGroup("ModifiersSharedEventsGroup").withReceiveHandledEvents(true)
                        .withXAxisDragModifier().withReceiveHandledEvents(true).withDragMode(AxisDragModifierBase.AxisDragMode.Pan).build()
                        .build());
            }
        });

and then added the surface to the vertical group.
verticalGroup.addSurfaceToGroup(sciChartSurface);

Also while im at it, the documentation doesnt give any explanation for what stuff does.
Some nice tutorials would be nice that actually explain what methods do.

…I dont even know what “updateSuspender” does.

Thanks
Aidan

Version
3
  • You must to post comments
Best Answer
1
0

Hi Aidan,

Thanks for your questions.

To share touch events among modifiers from several charts you need to add chart modifiers collection into same motion event group:

 chart1.getChartModifiers().add(sciChartBuilder.newModifierGroup()
            //add modifier group from chart1 into shared motion event group
            .withMotionEventsGroup("ModifiersSharedEventsGroup").withReceiveHandledEvents(true)
            // need to set receiveHanldeEvents flag to receive events from other chart
            .withZoomPanModifier().withReceiveHandledEvents(true) 
            .build());

 chart2.getChartModifiers().add(sciChartBuilder.newModifierGroup()
            //add modifier group from chart2 into shared motion event group
            .withMotionEventsGroup("ModifiersSharedEventsGroup").withReceiveHandledEvents(true)
            // need to set receiveHanldeEvents flag to receive events from other chart
            .withZoomPanModifier().withReceiveHandledEvents(true)
            .build());

This should fix the problem with pan between several charts.

Regarding the purpose of VerticalGroup class – it is helper class which is used to synchronize width of y axes which are placed in several charts. If you take a look on Multi-Pane Stock Chart example you should notice that the width of all YAxes on the right side is the same – all YAxes in vertical group reserve space which is required to draw axis with largest labels. This allows to synchronize size of viewport area ( place where all renderable series are drawn ) in case if you use several charts which are stacked vertically.

Regarding UpdateSuspender.using() method – it is helper method which is used to avoid unnecessary redrawing of chart. It suspends redrawing of chart while the specified Runnable is executed. In case of Multi-Pane Stock Chart example this allows to add all axes and renderable series with data series and redraw chart only once after all parts of chart are ready for drawing. This allows to reduce CPU usage and improve chart framerate. Without suspending updates chart automatically tries to redraw itself if you change something ( add axes, renderable series, change series style etc )

And yes, we’re working on new tutorials and extension of our documentation. We hope to release it in the nearest future.

Hope it helps!

Best regards,
Yura

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies