2014-02-19 29 views
1

開始我能夠與當前時間繪製的串行數據。假設我給myPane.XAxis.Scale.Min = 0;和一些最大值,我怎麼讓他們反映在「list.add(...,價值);」繪製上Zedgraph輸入串行數據,X軸從00:00

「...」是我無法計算應該是什麼通過。我使用下面的代碼HH:mm:ss。不過,我需要的X軸是這樣的,從00:00開始,直到說5分鐘。

myPane.XAxis.Scale.MaxAuto = true; 
myPane.XAxis.Scale.MinAuto = true; 
myPane.XAxis.Type = AxisType.Date; 
myPane.XAxis.Scale.Format = "HH:mm:ss"; 
myPane.Legend.Position = ZedGraph.LegendPos.TopCenter; 

DateTime now = new DateTime();
now = DateTime.Now; double timestamp = new XDate(now);
list.Add(timestamp, f);

我會感激你的建議

回答

1

我不知道它可以幫助你,但是這是我的實時數據繪製的代碼。

/*Initial pane settings*/ 
pane.XAxis.Type = AxisType.Date; 
pane.XAxis.Scale.Format = "dd/MM/yy\nH:mm:ss"; 
pane.XAxis.Scale.Min = (XDate)(DateTime.Now); 
//Shows 25 seconds interval. 
pane.XAxis.Scale.Max = (XDate)(DateTime.Now.AddSeconds(25)); 
pane.XAxis.Scale.MinorUnit = DateUnit.Second; 
pane.XAxis.Scale.MajorUnit = DateUnit.Minute; 
pane.XAxis.MajorTic.IsBetweenLabels = true; 
pane.XAxis.MinorTic.Size = 5; 

/*Real time plotting*/ 
XDate time = new XDate(DateTime.Now.ToOADate()); 
LineItem curve= curve= myPane.CurveList[0] as LineItem; 
IPointListEdit list = list = curve.Points as IPointListEdit; 
list.Add(time,data); 
//Scale pane if current time is greater than the initial xScale.Max 
Scale xScale = zgcMasterPane.MasterPane.PaneList[0].XAxis.Scale; 
if (time.XLDate > xScale.Max) 
{ 
    xScale.Max = (XDate)(DateTime.Now.AddSeconds(5)); 
    xScale.Min = (XDate)(DateTime.Now.AddSeconds(-20)); 
} 
+0

謝謝!我會檢查出來的 – Porcupine