日期:2014-05-18 浏览次数:21246 次
/// <summary> /// 目标值系列曲线 /// </summary> private Series DestSeries { get { return chartMain.Series.Count > 0 ? chartMain.Series[0] : null; } } /// <summary> /// X轴值范围 /// </summary> private AxisRange XRange { get { SwiftPlotDiagram diagram = chartMain.Diagram as SwiftPlotDiagram; if (diagram != null) return diagram.AxisX.Range; return null; } } private void SetChartData(CollectPointData pointData) { if (this.InvokeRequired) { this.Invoke(new Action<CollectPointData>(SetChartData), pointData); } else { decimal colValue = pointData.Value; RealSeries.Points.Add(new SeriesPoint(pointData.Time, colValue)); float minTime = pointData.Time - 30f; for (int i = 0; i < DestSeries.Points.Count; i++) { if (DestSeries.Points[i].NumericalArgument > minTime) { DestSeries.Points.RemoveRange(0, i); break; } } XRange.SetMinMaxValues(minTime, pointData.Time); } } public class CollectPointData { public CollectPointData() { } public CollectPointData(float time, decimal value) : this() { this.Time = time; this.Value = value; } public float Time { get; set; } public decimal Value { get; set; } }