This is a migrated thread and some comments may be shown as answers.

Synchronizing ChartView and TimeBar

3 Answers 95 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 06 Dec 2014, 03:13 AM
I have a TimeBar in sync with the zoom/pan of multiple ChartViews. I have code that successfully converts between the time ranges of the TimeBar and the Pan/Zoom properties of the ChartViews, and all works well until I try to sync between a TimeBar and multiple ChartViews.

The execution logic goes like this:

Change the TimeBar
TimeBar change event is fired, ChartViews are updated.
ChartView pan/zoom change events are fired. TimeBar is updated, other ChartViews are updated.
TimeBar and ChartView change events are fired. TimeBar is updated, other ChartViews are updated...
etc.

... and so the application hangs from infinite event recursion. The common approach to prevent this is using a bool as a flag to prevent further execution, but this doesn't work. It seems like the assignment of the pan/zoom properties of ChartView objects are delegated through i.e. Dispatcher.BeginInvoke, since the sub-events aren't fired in-between the times where the recursion flag is set.

My current idea is to set the flag to true and set a timer i.e. 100ms later to reset the flag to false, but I'd like to know if there's a less hacky way to do this?

3 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 09 Dec 2014, 09:13 AM
Hi Tyler,

If the calculations are accurate, there should be no infinite recursion. If the chart updates the timebar, and the timebar updates the chart with the same values it has - there should be no change notifications. Unless there are double rounding errors, of course.

We actually have a TimeBarOverChartView sample in our sdks. I modified it, and I am sending the result to you. In the attached project, you can see that I have integrated three charts and a single timebar. We prefer to use the zoom range api for this - HorizontalZoomRangeStart and End properties, instead of the Zoom and PanOffset properties.

Do check the attached project and see if you can adopt the same approach into your app. The attached project does not use any flag to stop the updates. We rely on the calculations being accurate. I hope this resolves the issue at hand. Let us know how it goes. Feel free to contact us again if you need more information.

Regards,
Petar Marchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tyler
Top achievements
Rank 1
answered on 09 Dec 2014, 04:23 PM
Hey Petar, thanks for the response.

When was this zoom range API introduced? We're using some 2013 version of the WPF UI components (2013.2.724.40) and RadCartesianChart doesn't seem to expose the HorizontalZoomRangeStart/End properties.
0
Petar Marchev
Telerik team
answered on 10 Dec 2014, 08:52 AM
Hello Tyler,

You are using 2013 Q2 SP, where the feature was introduced 2013 Q3. We hope that you can upgrade to the latest version as many things have been improved.

Regards,
Petar Marchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ChartView
Asked by
Tyler
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Tyler
Top achievements
Rank 1
Share this question
or