2014-05-07 37 views
0

我正在嘗試使用圖表控件來顯示折線圖中兩個單獨項目之間的差異。在圖表控件上顯示兩組數據點?

每一個項目都有一個二維陣列狀的下面:

double[,] a = { {1, 2}, {4, 5} }; 

如何添加每個這些陣列的如在圖表中控制一個單獨的系列?

回答

0

由於文檔是艾哈邁德給了我管理弄明白。

我正在寫我如何設法讓它工作,以防像我這樣的人無法將他們的頭圍住圖表控件。他們對我有點困惑。

我把填充我的圖表有兩個單獨的一系列數據,最簡單的路線是這樣的:

// set chart 
Chart compareChart = dropoffChartForm.dropoffDamageChart; 

// set chart basics 
compareChart.Series.Clear(); // clear existing series 
compareChart.ChartAreas[0].AxisX.Interval = 10.0; // interval of striplines 
compareChart.ChartAreas[0].AxisX.Minimum = 0; // minimum of X axis 
compareChart.ChartAreas[0].AxisX.Maximum = 100; // maximum of X axis 
compareChart.ChartAreas[0].AxisX.Title = "Meters"; // title of X axis 
compareChart.ChartAreas[0].AxisY.Title = "Damage per Bullet"; // title of Y axis 

// add A series 
compareChart.Series.Add(A.name); 
compareChart.Series[A.name].Points.DataBindXY(A.pointsX, A.pointsY); 
compareChart.Series[A.name].ChartType = SeriesChartType.Line; // set type to line chart 
compareChart.Series[A.name].Color = Color.Red; 

// only add B series if it differs from A series 
if (A.name != B.name) { 
    compareChart.Series.Add(B.name); 
    compareChart.Series[B.name].Points.DataBindXY(B.pointsX, B.pointsY); // each of these is a simple array of 4 doubles 
    compareChart.Series[B.name].ChartType = SeriesChartType.Line; // set type to line chart 
    compareChart.Series[B.name].Color = Color.Blue; 
} 

compareChart.Update(); // update chart after adding data