Panduranga Rao Sadhu
Panduranga Rao Sadhu

Reputation: 497

Resetting mschart with new series doesn't change yaxis range

I have a ms chart which shows a series which falls in the range 0.0004 to 0.0007. When I clear the chart and add a new series, it doesn't show anything since the new series falls in the range 0.0001 to 0.0003 and the chart still shows the Y axis labels from 0.0004 to 0.0007 Here is how I am doing it.

UpdateGraphswithnewdata()
{
    Chart1.Series.Clear();
    Series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
    Series1.Name = "Series1";
    Series1.Color = Color.Red;
    Series1.MarkerSize = 5;
    Series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;

    for (int i = 0; i < SitesList.Count; i++)
    {
       Series1.Points.AddXY((double)SitesList[i], Math.Round((double)RmseList[i], 4));
    }
    Chart1.ChartAreas[0].AxisY.IsStartedFromZero = false;
    Chart1.ChartAreas[0].AxisY.Title = "RMSE";
    Chart1.ChartAreas[0].AxisX.Title = "Site#";
    Chart1.Series.Add(Series1);
}

What is it that I have to reset?

Upvotes: 0

Views: 1314

Answers (1)

Panduranga Rao Sadhu
Panduranga Rao Sadhu

Reputation: 497

Got it. I had to clear chartareas and add them again. Thanks digEmAll you pointed me to the right direction.This worked for me.

var chartarea = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
Chart1.ChartAreas.Clear();
Chart1.ChartAreas.Add(chartarea);

Upvotes: 1

Related Questions