Jump to content
Software FX Community

Display problem with a secondary Y axis with a max value


User (Legacy)

Recommended Posts

I added a second Y axis to the right side of the graph and assigned the 

series to it. It works (I am able to set the gridlines, title, etc.) until

I set a max value and then neither the line nor the axis is displayed.

AxisY AddlAxisY = new AxisY();

// AddlAxisY.Max = 25; // if

this line is enabled, the line and the axis disapears. (the largest value

is 20)

AddlAxisY.Visible = true;

AddlAxisY.Position = AxisPosition.Far;

AddlAxisY.Title.Text = "Second Y Axis";

AddlAxisY.ForceZero = true;

AddlAxisY.Grids.Major.Visible = false;

AddlAxisY.Grids.Minor.Visible = false;

Chart.AxesY.Add(AddlAxisY);

Chart.Series[3].AxisY = AddlAxisY; // this is the

last of the 4 series on the graph.

Link to comment
Share on other sites

  • 1 year later...

 I ran into this problem myself and yes, setting both values makes it work.

However,  in my situation I cannot always set both of them. Usually, min is 0 if not set by the user, so I can assume that as default.But Max is based on the data. Is it possible to autocalculate the max or somehow let the charting engine decide what the maximum is for the secondary Y-axis?

 I could find the max myself but letting the chart decide will be much more elegant solution.  

Link to comment
Share on other sites

If the Secondary Y-Axis is set to AutoScale, you can call RecalcScale to adjust it Min and Max so that they fit the data.

After calling RecalcScale, you can set AutoScale to False and the Min and Max to the values you want, you can obtain the value for the Max right after calling RecalcScale to set it back. For example:

chart.AxisY2.AutoScale = true; 

chart.RecalcScale();

double min = chart.AxisY2.Min;

double max = chart.AxisY2.Max;

chart.AxisY2.AutoScale = false;

chart.AxisY2.Min = min; // Or the Min set by the user

chart.AxisY2.Max = max; // Or the Max set by the user

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...