4

I've got a winforms application which uses zed-graph library to plot graphs. When I right-click on the control (while application is running) a context menu shows up and I can choose Set Scale to default.
How do I achive this Set Scale to default-behaviour programmatically?

StuffHappens
  • 6,457
  • 13
  • 70
  • 95

2 Answers2

7

For each x- and y-axis following code is executed:

_scale._minAuto = true;
_scale._maxAuto = true;
_scale._majorStepAuto = true;
_scale._minorStepAuto = true;
_crossAuto = true;
_scale._magAuto = true;
_scale._formatAuto = true;

For more information easily look in the source code and search for "Set Scale to default".

SpeziFish
  • 3,262
  • 2
  • 28
  • 27
  • 4
    Fanou's comment: "The answer is not complete, you have to call the AxisChange() methode of your zedgraph component." – Peter O. Feb 17 '12 at 16:34
  • [`RestoreScale`](http://zedgraph.sourceforge.net/documentation/html/M_ZedGraph_ZedGraphControl_RestoreScale.htm) docs. – Roald May 15 '18 at 08:27
6

As of 2014, I couldn't get the above solution to work in VS2008, C#. But I succeeded doing the following:

    private void frmGraph_VisibleChanged(object sender, EventArgs e)
    {
        ZGraphComponent.RestoreScale(ZGraph.GraphPane);
    }

In the "VisibleChanged" event handler for the window containing the graph component, I call the "RestoreScale" method on the graph component, passing the main graph pane as the argument.

SteveB
  • 91
  • 1
  • 4