2014-03-03 74 views
0

我已經遠離.Net開發6年,回來了,我不得不創建一個圖表,我很高興看到這個控件,但它的工作方式有點煩人,反正,看看這張圖片: 2 charts圖表控件自定義標籤顏色

這兩張圖是同一張,唯一的區別是它們的寬度和高度,但正如你所看到的,在較小的上面,標籤是不對齊的。 起初我遇到了同樣的問題,但是在包含自定義標籤的情況下,增加了from和point之間的距離,但是同樣的技巧似乎不適用於較小的問題。 該點添加這種方式(這是直接添加,現在的隨機點,它會在未來成爲自動化)

serie1.Points.AddXY(1, 2000); 
      area.AxisX.CustomLabels.Add(0.5, 1.5, "1"); 
      serie1.Points.AddXY(2, 20000); 
      serie1.Points.AddXY(3, 30000); 
      serie1.Points.AddXY(4, 40000); 
      serie1.Points.AddXY(5, 60000); 
      serie1.Points.AddXY(6, 55000); 
      serie1.Points.AddXY(7, 59000); 
      serie1.Points.AddXY(8, 70000); 
      serie1.Points.AddXY(9, 90000); 
      serie1.Points.AddXY(10, 80000); 
      area.AxisX.CustomLabels.Add(9, 11, "10"); 
      serie1.Points.AddXY(11, 100000); 
      serie1.Points.AddXY(12, 95000); 
      serie1.Points.AddXY(13, 80000); 
      serie1.Points.AddXY(14, 75000); 
      serie1.Points.AddXY(15, 89000); 
      serie1.Points.AddXY(16, 110000); 
      serie1.Points.AddXY(17, 105000); 
      serie1.Points.AddXY(18, 115000); 
      serie1.Points.AddXY(19, 120000); 
      serie1.Points.AddXY(20, 130000); 
      area.AxisX.CustomLabels.Add(19, 21, "20"); 
      serie1.Points.AddXY(21, 115000); 
      serie1.Points.AddXY(22, 110000); 
      serie1.Points.AddXY(23, 120000); 
      serie1.Points.AddXY(24, 125000); 
      serie1.Points.AddXY(25, 124000); 
      serie1.Points.AddXY(26, 135000); 
      serie1.Points.AddXY(27, 140000); 
      serie1.Points.AddXY(28, 155000); 
      area.AxisX.CustomLabels.Add(27, 29, "28"); 

serie1是藍線,面是ChartArea。 任何人都知道如何確保標籤保持在同一行上?

回答

1

請試試這個:

area.AxisX.LabelAutoFitStyle = System.Web.UI.DataVisualization.Charting.LabelAutoFitStyles.None;