Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF Graph - Force graph to pan to a specific point that is not currently visible to to a zoom operation

I need to be able to pan to specific point on a wpf graph in order to bring that point back into view after a zoom operation has caused that point to now be out of the visible area.

 

I cannot use the ZoomFit or ZoomWindow for this since I need to keep the graph at the zoom factor to which the user has zoomed in.

 

I currently have a cursor displayed at the last point on which the user double-clicked, so this cursor would be the data point that needs to be brought back into view, preferably to the center of the screen.

 

I see the "Pan method but I'm not sure if this is what I should try to use. And if so, how are pan factors that are the required parameters for this method calculated?

 

 

 

0 Kudos
Message 1 of 2
(4,275 Views)

The factors on the Pan method represent the relative amount to move the the graph's current view. A value of 0.5,0.5 represents the center of the current view. Retrieving the cursor's position with the GetRelativePosition method, the amount we want to pan the graph is the difference between the the cursor's position and the target position:


    Point relativePosition = cursor.GetRelativePosition( );
    double xFactor = relativePosition.X - 0.5;
    double yFactor = relativePosition.Y - 0.5;
    graph.Pan( xFactor, yFactor );

~ Paul H
0 Kudos
Message 2 of 2
(4,265 Views)