2013-06-28 43 views
0

我有一個ms圖,它顯示了一系列在0.0004到0.0007的範圍內。 當我清除圖表並添加一個新系列時,它不顯示任何內容,因爲新系列的範圍在0.0001到0.0003之間,圖表仍顯示從0.0004到0.0007的Y軸標籤 以下是我如何操作。用新系列重新設置mschart不會改變yaxis範圍

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); 
} 

什麼是我必須重置?

回答

1

明白了。我必須清理chartareas並重新添加它們。感謝digEmAll你指出我正確的方向。這對我有效。

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