[英]How to Synchronize X Axis of Selected Panes in Zedgraph?
我正在尝试同步Zedgraph中选定窗格的X轴,
目前,我有三个窗格:
借助follwoing属性,我可以同步所有可用窗格的X轴:
zedGraphControl1.IsSynchronizeXAxes = true;
但我只想同步Pane-1和Pane-3 ,可以吗?
非常感谢您的时间... :)
是的。
基本上,您必须挂钩到ZoomEvent,然后使用FindPane
捕获已平移或缩放的窗格,将其Scale Min和Max属性应用到其他AxisChange
如果将其他一些Scale属性设置为Auto
,则执行AxisChange
。
假设要排除的GraphPane对象被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();
}
当然,由于同步现在是手动完成的,因此您需要设置
zedGraphControl1.IsSynchronizeXAxes = false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.