Chart Pan & Zoom synchro with another chart

4 posts, 0 answers
  1. Lukasz
    Lukasz avatar
    9 posts
    Member since:
    Jun 2011

    Posted 21 Jul 2011 Link to this post

    Hi,

    Is it possible to make Pan & Zoom synchronized with another chart with the same XAxis?
    I would also like to know whether it is possible to add point on the chart by taping? Like add line (2 points) by 2 taps or something similar.

    Best regards,
    Lukas S.
  2. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 22 Jul 2011 Link to this post

    Hi Lukasz,

    Thank you for the interesting question.

    The desired functionality can be easily achieved by creating an extended Pan&Zoom behavior that will synchronize both charts Zoom and PanOffset properties:

    public class ExtendedPanZoomBehavior : ChartPanAndZoomBehavior
    {
        private RadChart secondChart;
     
        public ExtendedPanZoomBehavior(RadChart secondChart)
        {
            this.secondChart = secondChart;
        }
     
        protected override bool OnGesture(GestureSample gesture)
        {
            bool handle = base.OnGesture(gesture);
     
            if (handle)
            {
                // synchronize the Pan and Zoom properties of the second chart
                this.secondChart.Zoom = this.Chart.Zoom;
                this.secondChart.PanOffset = this.Chart.PanOffset;
            }
     
            return handle;
        }
    }

    Regarding your second question - yes, you can easily add the desired functionality by implementing a PreviewGesture event handler. More information may be found in this blog post.

    I hope this information is useful. Do not hesitate to write us back should you have any other question.

    Greetings,
    Georgi
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. Lukasz
    Lukasz avatar
    9 posts
    Member since:
    Jun 2011

    Posted 22 Jul 2011 Link to this post

    Hi,

    Your answer about synchronize Pan&Zoom maybe will works but is one little problem.

            bool handle = base.OnGesture(gesture);//here is always false
     
            if (handle)
            {
                // synchronize the Pan and Zoom properties of the second chart
                this.secondChart.Zoom = this.Chart.Zoom;
                this.secondChart.PanOffset = this.Chart.PanOffset;
            }
     
            return handle;

    base.OnGesture(gesture) always returns false so nothing happens.
    I'm missing something?
    I added this code to run ExtendedPanZoomBehavior:
    ExtendedPanZoomBehavior PanZoomBehavior = new ExtendedPanZoomBehavior(chart2);
    chart1.Behaviors.Add(PanZoomBehavior);

    When I change condition to:
    if ((gesture.GestureType == GestureType.FreeDrag) ||
        (gesture.GestureType == GestureType.PinchComplete) ||
        (gesture.GestureType == GestureType.DoubleTap))
    {

    then works like expected :)

    ---
    About second question -> draw lines on chart. Yes I read about PreviewGesture event handler but is exist some canvas that I can use for add new line? A small example would be beneficial.

    Very thanks for help.
    Best regards, 
    Lukas
  5. Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 27 Jul 2011 Link to this post

    Hi Lukasz,

    Thanks for getting back to me.

    I suppose that you are using the BETA version of RadChart, where the "handled" flags was not properly updated. You may try to upgrade to the latest official tools - please note that there are several breaking changes (naming only) in RadChart. More information may be found here - API changes at the bottom of the page.

    As of drawing your own primitives on the chart surface - you will need to derive from RadChart to access its protected "RenderSurface" property. You may however simply overlay the chart with some UI panel that displays the desired visuals.

    We also have plans to expose the private AdornerLayer canvas, used by our predefined behaviors like Trackball to display their visual information. This feature will be most probably available for our service pack release, expected within a month.

    I hope this information is useful. Let me know if you have other questions.

    Kind regards,
    Georgi
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top