2012-07-08 43 views
2

我的圖表看起來都挺起勁。首先,x軸上的標籤太多了。對於兩個,它將x軸信息作爲DateTime對象。在這種情況下,我想顯示一天的時間。如何在.net圖表中設置軸屬性?

那麼我該如何讓這些標籤少一些,並讓標籤的內容成爲一個時間而不是日期呢?

http://i1120.photobucket.com/albums/l493/powerfulcrunch/chart.png

private void drawMinuteGraph(string data) 
    { 
     Chart chart = new Chart(); 
     Series series = new Series("default"); 
     series.ChartType = SeriesChartType.Line; 
     chart.Series.Add(series); 
     ChartArea chartArea = new ChartArea(); 
     chart.ChartAreas.Add(chartArea); 
     Axis x = new Axis(chartArea, AxisName.X); 
     x.LineWidth = 90; 
     Axis y = new Axis(chartArea, AxisName.Y); 
     Data[] _data = data.getHistory("History", data); 
     List<DateTime> dates = new List<DateTime>(); 
     List<double> values = new List<double>(); 
     foreach (Data __data in _data) 
     { 
      dates.Add(__data.timestamp); 
      values.Add(__data.value); 
     } 
     chart.Height = 150; 
     chart.Width = 150; 
     chart.Series["default"].Points.DataBindXY(dates, values); 
     flowLayoutPanel.Controls.Add(chart); 
    } 

回答