2014-03-25 60 views
0

我需要繪製直方圖,並且具有最小值和最大值的列應該具有與其他列不同的其他顏色,並且具有不同的寬度! 現在我已經完成了兩套,但這是錯誤的結果。MS Chart繪製條形圖

下面是我的代碼:

chart1.Series[0].Color = Color.Blue; 
int y; 
for (y = 0; y < lbls.Length; y++) 
{ 
chart1.Series[0].Points.AddY(costs[y]); 
chart1.ChartAreas[0].AxisX.CustomLabels.Add(new CustomLabel(y, y + 2, lbls[y], 0, LabelMarkStyle.LineSideMark)); 
} 

chart1.Series[1].Color = Color.Red; 
chart1.Series[1].Points.AddY(1500); 
chart1.ChartAreas[1].AxisX.CustomLabels.Add(new CustomLabel(y+4, y + 6, "lol", 0, LabelMarkStyle.LineSideMark)); 

它給我: a busy cat

回答

0

不太清楚如何改變特定列的寬度,但並更改特定i點顏色做以下。

'Loop through series to find min and max and then color label 
Chart1.Series[0].Points[i].Color = Color.Red 

P.S.

我不確定您是否可以更改一列寬。我有時使用Chart1.Series[0]("PixelPointWidth") = some integer來改變列系列的寬度,但看着msdn頁面,它似乎只能應用於系列而不是單獨的數據點。

PixelPointWidth @ MSDN

你可以只創建一個新的系列,並將其與剛剛最大值和最小值添加到chartarea,然後做Chart1.Series[1]("PixelPointWidth") = some integer,使他們比第一系列寬