1

I would like to know how to programmatically do the "Set scale to default" feature accesible via a right clic on a graph ? I can't manage to reproduce the correct behavior by using YAxis.Scale.Min YAxis.Scale.Max.

Guillaume Paris
  • 10,303
  • 14
  • 70
  • 145
  • 1
    possible duplicate of [Zed-Graph Set scale to default programmatically](http://stackoverflow.com/questions/7834604/zed-graph-set-scale-to-default-programmatically) – Bas Jan 08 '14 at 15:12

2 Answers2

2

I used the following code (replace GetActiveZgc() with your ZedGraphControl object).

    void ZoomReset()
    {
        GetActiveZgc().IsEnableHPan = false;
        GetActiveZgc().IsEnableHZoom = false;

        for (int i = GetActiveZgc().GraphPane.ZoomStack.Count * 2; i >= 0; i--)
        {
            GetActiveZgc().ZoomOut(GetActiveZgc().GraphPane);   
        }

        GetActiveZgc().GraphPane.XAxis.Scale.Min = 0;
        GetActiveZgc().GraphPane.YAxis.Scale.Min = 0;

        GetActiveZgc().IsEnableHPan = true;
        GetActiveZgc().IsEnableHZoom = true;

    }
2

It seems that contex menu item "Set scale to default" calls this:

ZedGraphControl.RestoreScale(ZedGraphControl.GraphPane);
AlexThunder
  • 168
  • 11