[英]Prevent Y2Axis from changing when user zooms ZedGraph
I am using a single ZedGraphControl to display 2 curves, one on the primary YAxis and another on the Y2Axis . 我使用单个ZedGraphControl显示2条曲线,一个在主Y轴和另一对Y2Axis 。 I want to make it so that when the user zooms in on the data manually, only the scale on the YAxis changes.
我要这样做,以便当用户手动放大数据时,仅YAxis上的比例会更改。
I could not find any method to lock the Y2Axis actually prevent changes in the first place. 我找不到任何锁定Y2Axis的方法,实际上实际上防止了更改。 I then thought I could just undo any changes to the axis in AxisChangeEvent , but changing the calls this event again, resulting in a infinite loop.
然后,我以为我可以撤消对AxisChangeEvent中的轴所做的任何更改,但是再次更改对这个事件的调用,导致无限循环。
In the typical fashion of this site, I came up with an answer while trying to properly ask the question. 以本网站的典型方式,我在尝试正确提出问题时想出了一个答案。
I just set a boolean flag at the beginning of my AxisChangeEvent to prevent the recursive calling. 我只是在AxisChangeEvent的开头设置了一个布尔标志,以防止递归调用。 Then reset the scale of the Y2Axis:
然后重置Y2Axis的比例尺:
private bool resizingAxis = false;
void GraphPane_AxisChangeEvent(ZedGraph.GraphPane pane)
{
if (!resizingAxis)
{
resizingAxis = true;
this.zedGraphControl1.GraphPane.Y2Axis.ResetAutoScale(pane, this.CreateGraphics());
resizingAxis = false;
}
}
This feels quite a bit like a hack, and I would love to hear any other possible solutions though. 这感觉有点像黑客入侵,不过,我很想听听其他可能的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.