SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

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.