How to set interval on Axis of Microsoft MS Chart in ASP.Net

Last Reply on Jul 03, 2014 05:45 AM By Priyanka12

Posted on Jul 03, 2014 03:53 AM

I want to fix the scale of y-axis to {1, 0.75, 0.50, 0.25, 0, -1, -0.75, -0.50, -0.25}
according to requirement y-axis value will always lie between 1 to -1.

C# code:

 

string query = "SELECT x,y from Table where DeletionDate is null";
DataTable dt = GetData(query);

double[] x = new double[dt.Rows.Count];
double[] y = new double[dt.Rows.Count];

for (int i = 0; i < dt.Rows.Count; i++)
{
    x[i] = Convert.ToDouble(dt.Rows[i][0].ToString());
    y[i] = Convert.ToDouble(dt.Rows[i][1].ToString());
}
Chart1.Series[0].Points.DataBindXY(x, y);

Chart1.ChartAreas["ChartArea1"].AxisY.Minimum = -1;
Chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 1;

I want to fix the scale of y-axis as defined above. Whatever the y-axis value coming from DB, it should plot in graph according to scale defined above.

How do achieve it in my above code.

Please reply

You are viewing reply posted by: Priyanka12 on Jul 03, 2014 05:45 AM.
Posted on Jul 03, 2014 05:45 AM

Solved using below line in code behind:

Chart1.ChartAreas["ChartArea1"].AxisY.Interval = 0.25;