0

我有 16 个图 [最大],每个图中有 4 条快线。在每张图中,3 条快线代表最小值、最大值和理想值。第 4 条快线是来自硬件的实际值。我必须对 18,000 个样本进行测试。所以,前 3 条快线已经画好了,当开关打开并且数据进来时,第 4 条快线就画好了。为了绘制第 4 条线,我使用方法 Series4.Add(actualvalue, "" , color.red) 。这就是问题所在。每次在第 4 行抽取样本。必须刷新图表才能查看该样本的绘图。这也重绘了其他 3 条快线,每条有 18,000 个样本。所以它一次又一次地重新绘制了那么多样本而没有使用。我只需要画第四条快线。我不能使用数组来填充值,然后将其分配为 fastline 的来源,因为我事先没有任何值。我尝试了 series4.repaint() 方法和 series4.refreshseries() 方法,但实际上并没有重新绘制第 4 个系列。我们必须刷新整个图表。因此,由于每条快线 [18,000] 中的样本数量很多,并且一张图有 4 条快线,总共有 16 个这样的图,因此它会降低性能。

我已经完成了 Series4.AutoRepaint = false, Series4.DrawAllPoints = false; Series4.XValues.Order = ValueListOrder.None , Series4.YValues.Order = ValueListOrder.None

有什么办法可以提高性能吗?谢谢你。

4

1 回答 1

2

我制作了一个简单的代码,其中我添加了 4 个带有 4 个 FastLines 的图表,每个 fastline 有 18000 个点,使用一个表格来添加一个初始化值,并且在我只更新 Series4 的值之后。对于我要绘制的值的数量,性能很好:

        public Form1()
     {
         InitializeComponent();
         InitializeChart();
     }

    // Steema.TeeChart.Styles.FastLine Series1;

     Timer timer1, timer2,timer3, timer4;
     Random r;
     DateTime dt;
   DateTime[] Xvalues1;
   double[] Yvalues1; 
     Steema.TeeChart.TChart tChart1, tChart2, tChart3,tChart4;
     private void InitializeChart()
     {

         tChart1 = new TChart();
         tChart2 = new TChart();
         tChart3 = new TChart();
         tChart4 = new TChart();
         this.Controls.Add(tChart1);
         this.Controls.Add(tChart2);
         this.Controls.Add(tChart3);
         this.Controls.Add(tChart4);

         //Initialize Locations and size

         this.Width = 908;
         this.Height = 600;

         //Location
         tChart1.Left = 12;
         tChart1.Top = 53;
         tChart2.Left = 468;
         tChart2.Top = 53;
         tChart3.Left = 12;
         tChart3.Top = 318;
         tChart4.Left = 468;
         tChart4.Top = 318;

         //Size
         tChart1.Width = 373;
         tChart1.Height = 236;
         tChart2.Width = 373;
         tChart2.Height = 236;
         tChart3.Width = 373; 
         tChart3.Height = 236;
         tChart4.Width = 373;
         tChart4.Height = 236;      

         tChart1.Aspect.View3D = false;
         tChart2.Aspect.View3D = false;
         tChart3.Aspect.View3D = false;
         tChart4.Aspect.View3D = false;

         tChart1.Legend.Visible = false;
         tChart2.Legend.Visible = false;
         tChart3.Legend.Visible = false;
         tChart4.Legend.Visible = false;


         tChart1.Panel.Gradient.Visible = false;
         tChart2.Panel.Gradient.Visible = false;
         tChart3.Panel.Gradient.Visible = false;
         tChart4.Panel.Gradient.Visible = false;


         tChart1.Axes.Bottom.AxisPen.Visible = false;
         tChart2.Axes.Bottom.AxisPen.Visible = false;
         tChart3.Axes.Bottom.AxisPen.Visible = false;
         tChart4.Axes.Bottom.AxisPen.Visible = false;

         tChart1.Axes.Left.AxisPen.Visible = false;
         tChart2.Axes.Left.AxisPen.Visible = false;
         tChart3.Axes.Left.AxisPen.Visible = false;
         tChart4.Axes.Left.AxisPen.Visible = false;

         //Series
         tChart1.AutoRepaint = false;
         tChart2.AutoRepaint = false;
         tChart3.AutoRepaint = false;
         tChart4.AutoRepaint = false;

         for (int i = 0; i < 4; i++)
         {
             new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
             new Steema.TeeChart.Styles.FastLine(tChart2.Chart);
             new Steema.TeeChart.Styles.FastLine(tChart3.Chart);
             new Steema.TeeChart.Styles.FastLine(tChart4.Chart);

             tChart1[i].XValues.DateTime=true;
             tChart2[i].XValues.DateTime = true;
             tChart3[i].XValues.DateTime = true;
             tChart4[i].XValues.DateTime = true;
             InitialDataSeries(tChart1[i]);
             InitialDataSeries(tChart2[i]);
             InitialDataSeries(tChart3[i]);
             InitialDataSeries(tChart4[i]);

         }

         //Axes labels
         tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
         tChart1.Axes.Bottom.Labels.Angle = 90;
         tChart2.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
         tChart2.Axes.Bottom.Labels.Angle = 90;
         tChart3.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
         tChart3.Axes.Bottom.Labels.Angle = 90;
         tChart4.Axes.Bottom.Labels.DateTimeFormat = "dd/MM";
         tChart4.Axes.Bottom.Labels.Angle = 90;
         tChart1.AutoRepaint = true;
         tChart2.AutoRepaint = true;
         tChart3.AutoRepaint = true;
         tChart4.AutoRepaint = true;
         tChart1.Refresh();
         tChart2.Refresh();
         tChart3.Refresh();
         tChart4.Refresh();

         //Timer
         timer1 = new Timer();
         timer1.Start();
         timer1.Interval = 100;
         timer1.Tick += new EventHandler(timer1_Tick);

     }

     void timer1_Tick(object sender, EventArgs e)
     {
         //See the chart data updated.
         tChart1[0].Visible = false;
         tChart1[1].Visible = false;
         tChart1[2].Visible = false;
         PopulateSeries(tChart1[3]);
         PopulateSeries(tChart2[3]);
         PopulateSeries(tChart3[3]);
         PopulateSeries(tChart4[3]);

     }
     private void PopulateSeries(Steema.TeeChart.Styles.Series Series1)
     {
         r = new Random();
         dt = DateTime.Now;
         tChart1.AutoRepaint = false;
         tChart2.AutoRepaint = false;
         tChart3.AutoRepaint = false;
         tChart4.AutoRepaint = false; 
         // show only 50 points - delete the rest
         while (Series1.Count > 10000)
         {
             Series1.Delete(0);

         }
         if (Series1.Count > 10000)
         {
            Series1.Delete(0);

         }
         else
         {
             for (int t = 0; t < 100; t++)
             {

                 Series1.Add(dt, r.Next(1000));
                 dt = dt.AddSeconds(15);
             }
         }
         tChart1.AutoRepaint = true;
         tChart2.AutoRepaint = true;
         tChart3.AutoRepaint = true;
         tChart4.AutoRepaint = true;
         tChart1.Refresh();
         tChart2.Refresh();
         tChart3.Refresh();
         tChart4.Refresh();
     }

     private void InitialDataSeries(Steema.TeeChart.Styles.Series Series1)
     {    
         //Arrays
         dt = DateTime.Now;
         r = new Random();
         Xvalues1 = new DateTime[18000];
         Yvalues1 = new double[18000];
         (Series1 as Steema.TeeChart.Styles.FastLine).DrawAllPoints = false;
         for (int j = 0; j < 18000; j++)
         {
             Xvalues1[j] = dt;
             dt = dt.AddSeconds(15);
             Yvalues1[j] = r.Next(1000);
         }

         Series1.Add(Xvalues1, Yvalues1);
     }

你能告诉我们它是否对你有帮助吗?另一方面,如果我的代码对您没有帮助,我建议您使用 TeeChartDirect2D,它非常适合 DSP 实时应用程序所需的高速数据吞吐量。请参阅白皮书《提升 Windows 窗体中的图形渲染性能》,了解详细信息。

谢谢,

于 2013-03-20T14:44:02.697 回答