2013-12-18 412 views
1

我有在它的圖表一個WinForm,在我的代碼我已經設置:C#WinForm的圖表,縮放和x軸的刻度顯示日期和時間

//Enable range selection and zooming end user interface 
     this.chart1.ChartAreas["ChartArea1"].CursorX.IsUserEnabled = true; 
     this.chart1.ChartAreas["ChartArea1"].CursorY.IsUserEnabled = true; 
     this.chart1.ChartAreas["ChartArea1"].CursorX.IsUserSelectionEnabled = true; 
     this.chart1.ChartAreas["ChartArea1"].CursorY.IsUserSelectionEnabled = true; 
     this.chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.Zoomable = true; 
     this.chart1.ChartAreas["ChartArea1"].AxisY.ScaleView.Zoomable = true; 
     this.chart1.ChartAreas["ChartArea1"].AxisX.ScrollBar.IsPositionedInside = true; 
     this.chart1.ChartAreas["ChartArea1"].AxisY.ScrollBar.IsPositionedInside = true; 

它放大後的選擇。但是,我的選擇僅限於網格線。而且,在選擇時,會出現紅叉,十字只會停留在固定的x軸值。我如何修改這樣的選擇不限於網格線/特定的固定x軸值?

我還設置x軸類型日期時間,即

this.chart1.Series[chanName].XValueType = ChartValueType.DateTime; 

然而,x軸僅顯示日期,而不是時間。我如何在x軸上顯示日期和時間?謝謝!

回答

4

您可以通過設置LabelStyle.Format屬性在x軸上顯示日期和時間。

this.chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "g"; 

您需要設置CursorX.Interval屬性。它的默認值是1.0。

this.chart1.ChartAreas["ChartArea1"].CursorX.Interval = 1/24.0/60.0; // 1 minute 

此外,您可以設置AxisX.ScaleView.MinSize屬性來限制選擇。其默認值未設置。

this.chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.MinSize = 1/24.0/60.0;