0

I am using a single ZedGraphControl to display 2 curves, one on the primary YAxis and another on the Y2Axis. I want to make it so that when the user zooms in on the data manually, only the scale on the YAxis changes.

I could not find any method to lock the Y2Axis actually prevent changes in the first place. 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.

Fr33dan
  • 4,227
  • 3
  • 35
  • 62

1 Answers1

0

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. Then reset the scale of the 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.

Fr33dan
  • 4,227
  • 3
  • 35
  • 62