Synchronizing ChartView and TimeBar

4 posts, 0 answers
  1. Tyler
    Tyler avatar
    7 posts
    Member since:
    Aug 2013

    Posted 05 Dec 2014 Link to this post

    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?
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 09 Dec 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tyler
    Tyler avatar
    7 posts
    Member since:
    Aug 2013

    Posted 09 Dec 2014 in reply to Petar Marchev Link to this post

    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.
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 10 Dec 2014 Link to this post

    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.

     
Back to Top