Reputation: 2060
I'm trying to synchronize X-Axis of selected panes in the Zedgraph,
Currently I've three panes:
with the help of the follwoing property I can synchronize X-Axis of all the available panes:
zedGraphControl1.IsSynchronizeXAxes = true;
but I want to synchronize just Pane-1 & Pane-3, is it possible?
Many Thanks for your time...:)
Upvotes: 1
Views: 1247
Reputation: 18031
Yes it is.
Basically, you have to hook to the ZoomEvent, then catch the pane which has been panned or zoomed, using FindPane
, apply its Scale Min and Max properties to the others, then do an AxisChange
if some other Scale properties are set to Auto
.
Assuming the GraphPane object you want to exclude is excludedGraphPane
void zedGraphControl1_ZoomEvent(ZedGraph.ZedGraphControl z, ZedGraph.ZoomState oldState, ZedGraph.ZoomState newState)
{
GraphPane pane;
using (var g = z.CreateGraphics())
pane = z.MasterPane.FindPane(z.PointToClient(MousePosition));
// The excludedGraphPane has to remain independant
if (pane == null || pane == excludedGraphPane)
return;
foreach (var gp in z.MasterPane.PaneList)
{
if (gp == pane || gp == excludedGraphPane)
continue;
gp.XAxis.Scale.Min = pane.XAxis.Scale.Min;
gp.XAxis.Scale.Max = pane.XAxis.Scale.Max;
gp.AxisChange(); // Only necessary if one or more scale property is set to Auto.
}
z.Invalidate();
}
Of course, because the synchronization is done manually now, you need to set
zedGraphControl1.IsSynchronizeXAxes = false;
Upvotes: 3