图表有几个问题 [英] Several problem with chart

查看:98
本文介绍了图表有几个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的图表区域中的系列有很多点时,我有几个问题,问题是我的GUI块,但图表点正在完美绘制,我的进度条和我的计时器(已用)停止运行,但是qhen ai将我的表单调整为小分辨率,它工作得很好。



(对不起我的英文优先)





我只做这个,我不使用图表,直接将积分添加到与图表对应的序列中



asing serie

I have several problems when i have a very large number of point on my series in my chart area, the problem is my GUI block, but chart point are ploting perfectly, my progress bar and my timer (elapsed) stop running, but qhen a i resize my form to small resolution, it work perfectly.

(sorry my english first)


I do only this, i dont use graph, add points directly to the seria asigned to the chart

asing serie

chart1.Series.Add(Serie[(int)showfactor]);





添加点



adding point

Serie[0].Points.AddXY(_CoordenadaX,_CoordenadaY / 1000);





show point



show point

chart1.Series.SuspendUpdates();
ConfigExperimentos[working].NuevoDato(nuevodato);
chart1.Series.ResumeUpdates();





建议是一个实时应用。







advice that is a real time app.


  private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e){
while (serialPort.BytesToRead >= 14)
    {
       for (int i = 0; i < 14; i++)
         {
           buffer[i] = (byte)serialPort.ReadByte();
         }
       if (buffer[13] == (byte)'F')
         {
           this.BeginInvoke(new InvokeDelegate(() =>
           {
             this.Invoke(new EventHandler(DatoRecibido));//this is a model class
            }));
         }
         else
         {
            while ((charend != (byte)'F') && (serialPort.BytesToRead != 0))
                    charend = (byte)serialPort.ReadByte();
         }
    }
}

推荐答案

我不太确定,但我有你是逐个添加积分的印象。



也许你可以尝试一次添加它们,包含之间的添加操作chart1.Series.SuspendUpdates(); chart1.Series.ResumeUpdates();
I'm not really sure, but I have the impression that you are adding the points one by one.

Maybe you could try to add them all at a time, enclosing the add operation between chart1.Series.SuspendUpdates(); and chart1.Series.ResumeUpdates();.


问题是datareceived事件和this.Invoke(其他事件),块I因为读取操作和绘制操作(在图表中),填充所有任务队列和UIthread之间永远不会保持活着,导致GUI不刷新直到datareceiver正在工作。



我需要用生产者 - 消费者模式和异步方法重构代码,以确保我调用刷新GUI并通知UItreahd io am这样做。



谢谢。
The problem was that the datareceived event and this.Invoke("other event"), block I because the read operation and paint operation (in chart), fill all the task queue and the UIthread never keep alive between that, result the GUI dont refresh until datareceiver is working.

I need to reestructure the code with producer-consumer pattern and async methods, to ensure that i call refresh the GUI and notify the UItreahd io am doing that.

Thanks.


这篇关于图表有几个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆