Ejemplo n.º 1
0
        private void updatePlot(PlotCurve plotM, int index, double y, int tiemLen, DateTime time)
        {
            try
            {
                //检查显示时间窗口,超过时间的予以移除
                foreach (var line in plotM.LinesCollect)
                {
                    int len = line.Elem.Points.Count; //获取点数
                    for (int i = 0; i < len; i++)
                    {
                        var t0 = DateTimeAxis.ToDateTime(line.Elem.Points[i].X);
                        if ((time - t0).TotalSeconds > tiemLen)
                        {
                            line.Elem.Points.RemoveAt(0);
                            i--;
                            len--;
                            continue; //此处大于60s 继续
                        }
                        break;        //没有大于则停止检测
                    }
                }



                plotM.LinesCollect.ElementAt(index).Elem.Points.Add(new DataPoint(DateTimeAxis.ToDouble(time), y));

                plotM.MplotModel.InvalidatePlot(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "更新显示");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 初始化单曲线显示
 /// </summary>
 /// <param name="plot">显示模型</param>
 /// <param name="pv">显示视图</param>
 /// <param name="title">标题</param>
 /// <param name="strLabel">图例</param>
 /// <param name="colors">颜色</param>
 private void InitSingleCurve(ref PlotCurve plot, OxyPlot.Wpf.PlotView pv, string title, string strLabel, OxyColor colors)
 {
     try
     {
         plot     = new PlotCurve(strLabel, colors, title);
         pv.Model = plot.GetModel();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "初始化显示plot" + title);
     }
 }