Question

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.

Was it helpful?

Solution

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;

    }

OTHER TIPS

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

ZedGraphControl.RestoreScale(ZedGraphControl.GraphPane);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top