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

Chart Pan & Zoom synchro with another chart

3 Answers 113 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lukasz
Top achievements
Rank 1
Lukasz asked on 21 Jul 2011, 01:01 PM
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.

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 22 Jul 2011, 10:33 AM
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!

0
Lukasz
Top achievements
Rank 1
answered on 22 Jul 2011, 02:33 PM
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
0
Georgi
Telerik team
answered on 27 Jul 2011, 12:47 PM
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!

Tags
Chart
Asked by
Lukasz
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Lukasz
Top achievements
Rank 1
Share this question
or