Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way set the Maximum Y axis to a Control Parameter/textbox or series Maximum in chart control or code behind?

I would like to be able to set the MAX and MIN depending on the data queried.
For example, if I have an Y (axis) "value" of 80 for a given time (X axis) and "target" of 70.
I would like AxisY Maximum= "target" +20 and AxisY Minimum = "target" -20

What I have tried:

<asp:ChartArea Name="ChartArea1">
<AxisY Maximum= "Auto" Minimum= "Auto" >
Posted
Updated 12-Mar-18 6:47am

1 solution

For anyone looking into this, I couldn't find a solution, but I did find where to prevent the Y axis from always starting at zero.
You can find the property in the property window under ChartAreas –> Axis Collection –> Y-Axis –> IsStartedFromZero or through code:
	
// Start Y-axis labeling from the minimum value in my dataset
this.Chart2.ChartAreas[0].AxisY.IsStartedFromZero = false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900