Search code examples
c#zedgraph

ZedGraph AxisChange() reset?


I'm using C#. When I use AxisChange() to adjust the axis on my graph, it works fine, until I go into the graph pane and manually zoom in and out.

After manually zooming in and out, the AxisChange() command no longer works. How can you get it so after the axis gets fixed, you can again use AxisChange()?


Solution

  • I've checked the code of AxisChange() method and I think this is because of following code:

                // if the ChartRect is not yet determined, then pick a scale based on a default ChartRect
            // size (using 75% of Rect -- code is in Axis.CalcMaxLabels() )
            // With the scale picked, call CalcChartRect() so calculate a real ChartRect
            // then let the scales re-calculate to make sure that the assumption was ok
            if ( _chart._isRectAuto )
            {
                PickScale( g, scaleFactor );
    
                _chart._rect = CalcChartRect( g );
                //this.pieRect = PieItem.CalcPieRect( g, this, scaleFactor, this.chartRect );
            }
    

    I’m not sure though, you should give a try copy line … outside the “if” clause and see what happens. Any way, try to debug the source code, it is good enough for understanding.