02-16-2015 06:08 PM
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?
02-17-2015 01:26 PM
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 );