none
chart控件

    问题

  • 我有三个chart控件,绑定数据之后,替换里面的数据,但是前面两个chart控件的曲线是一下子走好几个,第三个是一点一点走,请问什么原因?

    please verify my account

    2017年4月28日 7:25

全部回复

  • Hi,

    由于对你的程序一无所知,实在不能给出任何有意义的建议。

    你可以贴出相关的代码吗? 或者使用OneDrive上传可以复现你的问题的demo吗?

    为了使我们能够更好的理解你的问题,我希望你能够编辑你的问题,在你的问题中我们希望得到以下信息:

    1. 你的开发工具及环境,  比如winform,WPF...还是其它。 

    2. 出现你的问题的关键代码,或者可能导致你的问题的代码。

    3. 复现你的问题的步骤。

    4. 添加相关的截图以展示相关问题。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    2017年4月28日 8:57
  • Hi,

    由于对你的程序一无所知,实在不能给出任何有意义的建议。

    你可以贴出相关的代码吗? 或者使用OneDrive上传可以复现你的问题的demo吗?

    为了使我们能够更好的理解你的问题,我希望你能够编辑你的问题,在你的问题中我们希望得到以下信息:

    1. 你的开发工具及环境,  比如winform,WPF...还是其它。 

    2. 出现你的问题的关键代码。

    3. 复现你的问题的步骤。

    4. 添加相关的截图以展示相关问题。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    你好,我的问题需要内网才能访问数据,截图不能说明我的问题,只有录制视频,又不知道怎么录制和上传,

    就是winform的程序,收到c++服务器的数据,把数据放到chart里面,三个chart一起赋值,然后一屏幕后,替换chart里的数据,

    但是前两个chart的曲线是一段一段的前进,第三个是一点一点的前进,而且速度还快


    please verify my account

    2017年4月28日 9:01
  • 这怎么办?研究半天了,问题都没解决

    please verify my account

    2017年4月28日 9:02
  • 关键代码

         public async Task ConnectToServerAsync()
            {
                _endPoint = new IPEndPoint(IPAddress.Parse(txtAddress.Text), Convert.ToInt32(txtPort.Text));
                _client = new TcpClient();
                await _client.ConnectAsync(_endPoint.Address, _endPoint.Port);
                //MessageBox.Show("连接成功!");
                stream = _client.GetStream();
                this.Close();
                byte[] bytes2 = new byte[1024];
                //byte[] Stations = MyFrame.Station();
                //默认编码
                int bytesRead1 = await stream.ReadAsync(bytes2, 0, bytes2.Length);
                byte[] bytes1 = First();
                //写入数据
                await stream.WriteAsync(bytes1, 0, bytes1.Length);
                //实时数据端口,实时监测数据
                try
                {
                    while (true)
                    {
                        //实时数据长度222
                        byte[] bytes = new byte[3022];
                        if (stream != null)
                        {
                            //延迟0.5秒
                            // await Task.Delay(500);
                            int bytesRead = await stream.ReadAsync(bytes, 0, bytes.Length, cts.Token);
                            //获取头部
                            string head = Encoding.UTF8.GetString(bytes, 0, 4);
                            short Num = BitConverter.ToInt16(bytes, 4);
                            CommonHelper.SeisNum = Num;
                            short Symbol = BitConverter.ToInt16(bytes, 6);
                            short Len = BitConverter.ToInt16(bytes, 8);
                            short Ret = BitConverter.ToInt16(bytes, 10);
                            int Sec = BitConverter.ToInt32(bytes, 12);
                            CommonHelper.DateCode = Sec;
                            short Mse = BitConverter.ToInt16(bytes, 16);
                            DateTime s = new DateTime(1970, 1, 1);
                            s = s.AddSeconds(Sec);
                            string start = s.ToString("yyyy-MM-dd hh:mm:ss");
                            byte Sym = bytes[18];
                            byte Hea = bytes[19];
                            byte[] data1 = null;
                            if (Num == 0)
                            {
                                data1 = bytes.Skip(20).Take(Len / 3).ToArray();
                            }
                            else if (Num == 1)
                            {
                                data1 = bytes.Skip(20).Take(Len / 3).ToArray();
                            }
                            short[] arr = new short[data1.Length / 2];
                            for (int i = 0; i < arr.Length; i++)
                            {
                                arr[i] = BitConverter.ToInt16(data1, i * 2);
                            }
                            byte[] data2 = null;
                            if (Num == 0)
                            {
                                data2 = bytes.Skip(20 + Len / 3).Take(Len / 3).ToArray();
                            }
                            else if (Num == 1)
                            {
                                data2 = bytes.Skip(20 + Len / 3).Take(Len / 3).ToArray();
                            }
                            short[] arr2 = new short[data2.Length / 2];
                            for (int i = 0; i < arr2.Length; i++)
                            {
                                arr2[i] = BitConverter.ToInt16(data2, i * 2);
                            }
                            byte[] data3 = null;
                            if (Num == 0)
                            {
                                data3 = bytes.Skip(20 + Len / 3 * 2).Take(Len / 3).ToArray();
                            }
                            else if (Num == 1)
                            {
                                data3 = bytes.Skip(20 + Len / 3 *2).Take(Len / 3).ToArray();
                            }
                            short[] arr3 = new short[data3.Length / 2];
                            for (int i = 0; i < arr3.Length; i++)
                            {
                                arr3[i] = BitConverter.ToInt16(data3, i * 2);
                            }
                            int[] Iarr = new int[data1.Length / 4];
                            for (int i = 0; i < Iarr.Length; i++)
                            {
                                Iarr[i] = BitConverter.ToInt32(data1, i * 4);
                            }
                            int[] Iarr2 = new int[data2.Length / 4];
                            for (int i = 0; i < Iarr2.Length; i++)
                            {
                                Iarr2[i] = BitConverter.ToInt32(data2, i * 4);
                            }
                            int[] Iarr3 = new int[data3.Length / 4];
                            for (int i = 0; i < Iarr3.Length; i++)
                            {
                                Iarr3[i] = BitConverter.ToInt32(data3, i * 4);
                            }
                            int inter = 0;
                            if (Num == 0)
                            {
                                inter = 1000 / CommonHelper.Samp;
                            }
                            else if (Num == 1)
                            {
                                inter = 1000 / CommonHelper.Samp2;
                            }
                            short cheTot = (short)(Num + Symbol + Len + Ret + Sec + Mse + Sym + Hea + arr.Select(x => (int)x).Sum() + arr2.Select(x => (int)x).Sum() + arr3.Select(x => (int)x).Sum());
                          
                            int vvv = 2*10 / inter ;
                            //int zzz= 10 / inter*2 ;
                            List<MyModel> list = new List<MyModel>();
                            List<MyModel> list1 = new List<MyModel>();
                            if (CommonHelper.MyCount > CommonHelper.SX + (30000 / (1000 / CommonHelper.Samp)) - Len / 12)
                            {
                                CommonHelper.MyCount = CommonHelper.SX;
                                CommonHelper.MyCount2 = CommonHelper.SX;
                                CommonHelper.MyCount3 = CommonHelper.SX;
                                CommonHelper.MyCount4 = CommonHelper.SX;
                                CommonHelper.MyCount5 = CommonHelper.SX;
                                CommonHelper.MyCount6 = CommonHelper.SX;
                            }
                            foreach (int c in Iarr)
                            {
                     
                              
                           
                                //实体类
                                MyModel model = new MyModel();
                                //model.Date = CommonHelper.MyCount + inter / 10.0;
                                if (Num == 0)
                                {
                                    model.Date = CommonHelper.MyCount + 1;
    
                                    CommonHelper.MyCount = model.Date;
                                }
                                else if (Num == 1) {
                                    model.Date = CommonHelper.MyCount4 + 1;
                                    CommonHelper.MyCount4 = model.Date;
                                }
                                model.Value = (c);
                                model.Type = Num;
                          
                                model.Up = start;
                         
                                list.Add(model);
    
                          
                            }
                         
                            if (inter <= 10)
                            {
                                list1 = list.Where(p => p.Date % vvv == 0).Select(p => p).ToList();
                                if (list1.Count > 25)
                                {
                                    list1.RemoveRange(0, list1.Count() - 25);
                                }
                            }
                            else {
                                list1 = list;
                            }
         
    
                      
                            List<MyModel> list2 = new List<MyModel>();
                            List<MyModel> list22 = new List<MyModel>();
                            foreach (int c in Iarr2)
                            {
                                //实体类
                                MyModel model = new MyModel();
                                // model.Date = CommonHelper.MyCount2 + inter / 10.0;
    
                                if (Num == 0)
                                {
                                    model.Date = CommonHelper.MyCount2 + 1;
                                    CommonHelper.MyCount2 = model.Date;
                                }
                                else if (Num == 1)
                                {
                                    model.Date = CommonHelper.MyCount5 + 1;
                                    CommonHelper.MyCount5 = model.Date;
                                }
    
                             
                                model.Value = (c);
                                model.Up = start;
                                model.Type = Num;
                                //if (CommonHelper.MyCount % 3 != 0)
                                list2.Add(model);
                                // i++;
                            }
                            //list22 = list2;
    
                            if (inter <= 10)
                            {
                                list22 = list2.Where(p => p.Date % vvv == 0).Select(p => p).ToList();
                                if (list22.Count > 25)
                                {
                                    list22.RemoveRange(0, list1.Count() - 25);
                                }
                            }
                            else {
                                list22 = list2;
                            }
                            
                            //if (list22.Count > 25)
                            //{
                            //    list22.RemoveRange(0, list22.Count() - 25);
                            //}
                            //list22 = list2.Where((num, index) => index % vvv == 0).Select(p => p).ToList();
                            List<MyModel> list3 = new List<MyModel>();
                            List<MyModel> list33 = new List<MyModel>();
                            foreach (int c in Iarr3)
                            {
                                //实体类
                                MyModel model = new MyModel();
                                //model.Date = CommonHelper.MyCount3 + inter / 10.0;
    
                                if (Num == 0)
                                {
    
                                    model.Date = CommonHelper.MyCount3 + 1;
                                    CommonHelper.MyCount3 = model.Date;
                                }
                                else if (Num == 1)
                                {
                                    model.Date = CommonHelper.MyCount6 + 1;
                                    CommonHelper.MyCount6 = model.Date;
                                }
    
    
                                // model.Value = (c - avg3);
                                model.Type = Num;
                                model.Value = (c);
                                model.Up = start;
                                list3.Add(model);
                            }
                            //list33 = list3;                       
                            //list33 = list3.Where((num, index) => index % vvv == 0).Select(p => p).ToList();
    
                            if (inter <= 10)
                            {
                                list33 = list3.Where(p => p.Date % vvv == 0).Select(p => p).ToList();
                                if (list33.Count > 25)
                                {
                                    list33.RemoveRange(0, list1.Count() - 25);
                                }
                            }
                            else
                            {
                                list33 = list3;
                            }
    
                          
                            //if (list33.Count > 25)
                            //{
                            //    list33.RemoveRange(0, list33.Count() - 25);
                            //}
                            //把数据传到另一个窗体,带chart控件的窗体
                            OnDataChanged(new DataChangedEventArgs(list1, list22, list33));
                            if (stream != null)
                                //写入数据
                                await stream.WriteAsync(ResSuccess(), 0, ResSuccess().Length);
                        }
                    }
                }
                catch (ObjectDisposedException ex)
                {
                    return;
                }
                catch (OperationCanceledException ex)
                {
                    return;
                }
                //MessageBox.Show(serverResponse);
                //        }
                //    }
                //}          //}
                catch (SocketException se)
                {
                    MessageBox.Show("主机无反应!");                //throw;
                }
            }


    please verify my account


    • 已编辑 lctk 2017年4月28日 9:07
    2017年4月28日 9:06
  • chart窗体回调函数

         public void Test(object sender, DataChangedEventArgs e)
            {
                //UI线程,加载到窗体
                //this.Invoke(new MethodInvoker(() =>
                //{
                if (toolStripButton3.Enabled == false)
                {
                    MyResi();
                    查询ToolStripMenuItem.Enabled = true;
                    设置ToolStripMenuItem.Enabled = true;
                    toolStripButton3.BackColor = Color.FromArgb(51, 204, 255);
                    toolStripButton1.Enabled = false;
                    toolStripButton3.Enabled = true;
                    toolStripButton4.Enabled = true;
                    label2.Text = e.List3.FirstOrDefault().Up;
                    groupBox2.Visible = true;
                    toolStripButton3.Enabled = true;
                    toolStripButton4.Enabled = true;
                    CommonHelper.IsSelected = true;
                }
                //}));
                //判断是否点击显示按钮
                if (toolStripButton4.BackColor == Color.FromArgb(51, 204, 255))
                {
                    //await Task.Run(() =>
                    //{
                    lock (sb)
                    {
                        if (CommonHelper.SX == 0)
                        {
                            CommonHelper.SX = e.List1.FirstOrDefault().Date;
                        }
                        if (e.List1.FirstOrDefault().Type == 0)
                        {
                            if (CommonHelper.MyList.Count > CommonHelper.myX / 2 - e.List1.Count())
                            {
                                List<MyModel> temList = (from c in CommonHelper.MyList.Where(p => p != null)
                                                         join z in e.List1.Where(p => p != null)
                                                             on c.Date equals z.Date
                                                         select c).ToList();
                                CommonHelper.MyList = CommonHelper.MyList.Except(temList).Where(p => p != null).ToList();//差集  
                                CommonHelper.MyList.AddRange(e.List1);
                                List<MyModel> temList2 = (from c in CommonHelper.MyList2.Where(p => p != null)
                                                          join z in e.List2.Where(p => p != null)
                                                              on c.Date equals z.Date
                                                          select c).ToList();
                                x = x + temList.Count;
                                if (x > CommonHelper.myX / 2)
                                {
                                    x = x - CommonHelper.myX / 2;
                                }
                                CommonHelper.MyList2 = CommonHelper.MyList2.Except(temList2).Where(p => p != null).ToList();//差集  
                                CommonHelper.MyList2.AddRange(e.List2);
                                List<MyModel> temList3 = (from c in CommonHelper.MyList3.Where(p => p != null)
                                                          join z in e.List3.Where(p => p != null)
                                                              on c.Date equals z.Date
                                                          select c).ToList();
                                CommonHelper.MyList3 = CommonHelper.MyList3.Except(temList3).Where(p => p != null).ToList();//差集  
                                CommonHelper.MyList3.AddRange(e.List3);
                            }
                            else
                            {
                                CommonHelper.MyList.AddRange(e.List1);
                                CommonHelper.MyList2.AddRange(e.List2);
                                CommonHelper.MyList3.AddRange(e.List3);
                            }
    //调用chart控件
                            DrawSpline1();
                            DrawSpline2();
                            DrawSpline3();
                            All();
                            if (lbl1.Visible == false)
                            {
                                lbl1.Visible = true;
                                lbl2.Visible = true;
                                lbl3.Visible = true;
                                lbl4.Visible = true;
                                lbl5.Visible = true;
                                lbl6.Visible = true;
                            }
                        }
                        else if (e.List1.FirstOrDefault().Type == 1)
                        {
    
                            if (CommonHelper.MyList4.Count > CommonHelper.myX2 / 2 + 1 - e.List1.Count())
                            {
    
                                //List<MyModel> temList = (from t1 in CommonHelper.MyList
                                //                         from t2 in e.List1
                                //                         where t1.Date != t2.Date
                                //                         select t1).ToList();
                                List<MyModel> temList = (from c in CommonHelper.MyList4
                                                         join z in e.List1
                                                             on c.Date equals z.Date
                                                         select c).ToList();
                                //select c).ToList();
                                CommonHelper.MyList4 = CommonHelper.MyList.Except(temList).ToList();//差集  
                                CommonHelper.MyList4.AddRange(e.List1);
                                List<MyModel> temList2 = (from c in CommonHelper.MyList5
                                                          join z in e.List2
                                                              on c.Date equals z.Date
                                                          select c).ToList();
                                //x = x + temList2.Count;
                                //if (x > CommonHelper.myX2 / 2)
                                //{
                                //    x = x - CommonHelper.myX2 / 2 < 0 ? 0 : x - CommonHelper.myX2 / 2;
                                //}
                                CommonHelper.MyList5 = CommonHelper.MyList5.Except(temList2).ToList();//差集  
                                CommonHelper.MyList5.AddRange(e.List2);
                                List<MyModel> temList3 = (from c in CommonHelper.MyList6.Where(p => p != null)
                                                          join z in e.List3.Where(p => p != null)
                                                              on c.Date equals z.Date
                                                          select c).ToList();
                                CommonHelper.MyList6 = CommonHelper.MyList6.Except(temList3).Where(p => p != null).ToList();//差集  
                                CommonHelper.MyList6.AddRange(e.List3);
                            }
                            else
                            {
                                CommonHelper.MyList4.AddRange(e.List1);
                                CommonHelper.MyList5.AddRange(e.List2);
                                CommonHelper.MyList6.AddRange(e.List3);
                            }
    
                            DrawSpline4();
                            DrawSpline5();
                            DrawSpline6();
                            if (lbl8.Visible == false)
                            {
                                lbl1.Visible = true;
                                lbl2.Visible = true;
                                lbl3.Visible = true;
                                lbl4.Visible = true;
                                lbl5.Visible = true;
                                lbl6.Visible = true;
                                lbl7.Visible = true;
                                lbl8.Visible = true;
                                lbl9.Visible = true;
                                lbl10.Visible = true;
                                lbl11.Visible = true;
                                lbl12.Visible = true;
                            }
                        }
                        //if (e.List1.FirstOrDefault().Type == 0)
                        //{
                        //    //this.BeginInvoke(new MethodInvoker(() =>
                        //    //{
    
                        //    //}));
                        //}
                        //else if (e.List1.FirstOrDefault().Type == 1)
                        //{
                        //    this.BeginInvoke(new MethodInvoker(() =>
                        //    {
    
                        //    }));
                        //}
                    }
                    //});
                    //await Task.Run(() =>
                    //{
                    //    CommonHelper.MyList2.AddRange(e.List2);
                    //    if (CommonHelper.MyList2.Count > 1000)
                    //    {
    
                    //        CommonHelper.MyList2.RemoveRange(0, CommonHelper.MyList2.Count - 1000);
                    //    }
                    //});
                    //异步操作数据
                    //await Task.Run(() =>
                    //{
                    //    CommonHelper.MyList3.AddRange(e.List3);
                    //    if (CommonHelper.MyList3.Count > 1000)
                    //    {
                    //        CommonHelper.MyList3.RemoveRange(0, CommonHelper.MyList3.Count - 1000);
                    //    }
                    //});
                    //把数据放到UI线程
    
                    // button1.Text = e.List.FirstOrDefault().Type == 0 ? "UD" : e.List.FirstOrDefault().Type == 1 ? "NS" : e.List.FirstOrDefault().Type == 2 ? "EW" : "";
                    //Graphics g = this.groupBox3.CreateGraphics();
                    //g.DrawLines(new Pen(Color.Red), createData(100, 200, e.List));
                    //g.DrawLines(new Pen(Color.Red), createData(200, 500, 5));
                    //g.DrawLines(new Pen(Color.Red), createData(300, 500, 5));
                    // this.zedGraphControl1.BorderStyle = BorderStyle.None;
                    //this.zedGraphControl1.GraphPane.Border.IsVisible = false;
                    //this.zedGraphControl2.MasterPane.Border.IsVisible = false; 
                    // zedGraphControl1.BorderStyle = BorderStyle.None;
                    //GraphPane pane2 = this.zedGraphControl1.GraphPane;
                    // pane2.XAxis.Type = AxisType.Date;
                    //pane2.XAxis.Type = AxisType.Date;
                    // pane2.XAxis.Scale.Format = "hhmmssff";
                    //pane2.CurveList.Clear();
                    //pane2.Title.Text = "NS实时值";
                    //pane2.XAxis.Title.Text = "时间";
                    //pane2.YAxis.Title.Text = "数值";
                    //pane2.XAxis.Scale.MajorStep = 4;
                    //pane2.XAxis.Scale.MinorStep = 1;
                    // pane2.YAxis.Scale.MajorStep = 1;
                    //pane2.XAxis.Scale.MajorStep = (pane2.XAxis.Scale.Max - pane2.XAxis.Scale.Min) / 10.0;    //刻度间隔大小
                    //pane2.XAxis.Scale.MinorStep = (pane2.XAxis.Scale.Max - pane2.XAxis.Scale.Min) / 50.0;
                    //pane2.YAxis.Scale.MajorStep = (pane2.YAxis.Scale.Max - pane2.YAxis.Scale.Min) / 5.0;
                    //pane2.YAxis.Scale.MinorStep = (pane2.YAxis.Scale.Max - pane2.YAxis.Scale.Min) / 25.0;
                    //zedGraphControl2.
                    //pane2.YAxis.MajorGrid.IsVisible = true;
                    //pane2.XAxis.Scale.Max = 23999999;
                    //pane2.XAxis.Scale.Min = 0;
                    //pane2.XAxis.Scale.Min = 42832;
                    //pane2.XAxis.MajorGrid.DashOff = 280;
                    // pane2.XAxis.Scale.Min = 0;
                    // pane2.XAxis.Scale.MinorStep = 1;
                    // pane2.XAxis.MajorGrid.DashOff = 280;
                    //pane2.XAxis.Scale.Min = 0;
                    // pane2.XAxis.Scale.MajorStep = 1000;
                    //FileStream fs = new FileStream("evt_chn1.txt", FileMode.Open, FileAccess.Read, FileShare.Read);
                    //StreamReader Reader = new StreamReader(fs);
                    //while (!Reader.EndOfStream)
                    //{
                    //    string sline = Reader.ReadLine();
                    //    if (sline.Length > 0)
                    //    {
                    //        string yy = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                    //        double cc = Convert.ToDouble(sline.Replace("-", ""));
                    //        XDate date = new XDate(Convert.ToInt32(yy.Substring(0, 4)), Convert.ToInt32(yy.Substring(4, 2)), Convert.ToInt32(yy.Substring(6, 2)), Convert.ToInt32(yy.Substring(8, 2)), Convert.ToInt32(yy.Substring(10, 2)), Convert.ToInt32(yy.Substring(12, 2)), Convert.ToInt32(yy.Substring(14, 3)));
                    //        list2.Add(Convert.ToInt32(yy.Substring(14, 3)), cc);
                    //        // list1.Add(cc, cc);
                    //    }
    
                    //}
                    // pane2.chart1.Border.IsVisible = false;
                    //  pane2.XAxis.IsVisible = false;
                    // pane2.YAxis.IsVisible = false;
                    //PointPairList list = new PointPairList();
                    //if (pane2.CurveList.Count > 0)
                    //{
                    //    LineItem curve = pane2.CurveList[0] as LineItem;
                    //    list = curve.Points as PointPairList;
                    //}
                    //if (list.Count == 0 || list.Count == 200)
                    //{
                    //    foreach (MyModel model in e.List)
                    //    {
    
                    //        XDate date = new XDate(Convert.ToInt32(model.Date.Substring(0, 4)), Convert.ToInt32(model.Date.Substring(4, 2)), Convert.ToInt32(model.Date.Substring(6, 2)), Convert.ToInt32(model.Date.Substring(8, 2)), Convert.ToInt32(model.Date.Substring(10, 2)), Convert.ToInt32(model.Date.Substring(12, 2)), Convert.ToInt32(model.Date.Substring(14, 3)));
                    //        list.Add(date, model.Value);
                    //    }
                    //}
                    //  //pane2.XAxis.Scale.Max = ;
                    //if (pane2.CurveList.Count == 0)
                    //{
                    //LineItem curve1=    pane2.AddCurve("测试", list, Color.Red, SymbolType.Square);
                    //curve1.IsOverrideOrdinal = true;
                    //}
                    //  pane2.AddCurve("张飒", list1, Color.Green, SymbolType.None);
                    //this.zedGraphControl1.AxisChange();
                    //this.zedGraphControl1.Refresh();
    
                    //操作数据,第二个图形
    
                    //button2.Text = e.List.FirstOrDefault().Type == 0 ? "UD" : e.List.FirstOrDefault().Type == 1 ? "NS" : e.List.FirstOrDefault().Type == 2 ? "EW" : "";
                    //同步到UI线程
                    //this.BeginInvoke(new MethodInvoker(() =>
                    //{
                    //}));
                    ////同步到UI线程
                    //this.BeginInvoke(new MethodInvoker(() =>
                    //{
    
                    //}));
                }
                //button3.Text = e.List.FirstOrDefault().Type == 0 ? "UD" : e.List.FirstOrDefault().Type == 1 ? "NS" : e.List.FirstOrDefault().Type == 2 ? "EW" : "";
            }


    please verify my account

    2017年4月28日 9:11
  • 要不远程给我看一下吧,,,,,,

    please verify my account

    2017年4月28日 9:12
  • Hi,

    如果你的三个chart控件的数据绑定和刷新的方式是一样的,那么就不是chart控件的问题, 问题可能来源于你的数据,如你第三条数据本身返回的数据就比前两条数据少,在同频率的刷新下, 你第三条数据显示就比前两条少了。请从数据入手检查, 试着将接收的数据打印出来看看。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月28日 9:16
  • 三个数据都是一样的,我看了,一直都是一样,

    please verify my account

    2017年4月28日 9:18

  • please verify my account

    2017年4月28日 9:21
  • 而且有的时候,只有第三个在动,前两个停止不动了

    please verify my account

    2017年4月28日 9:22

  • please verify my account

    2017年4月28日 9:22

  • please verify my account

    2017年4月28日 9:23
  • Hi,

    >> 三个数据都是一样的,我看了,一直都是一样,

    从你的chart上看,你的数据是不同的,因为曲线不同。我建议你检查每个刷新频率的数据。

    >> 而且有的时候,只有第三个在动,前两个停止不动了

    前面两个不动,是不是因为服务器没有返回数据。

    建议你还是一步一步的debug你的程序,观察数据到底是如何返回的。

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月28日 9:40
  • 曲线是不同,但是数据量是相同的,x轴的数据相同

    都有数据返回,我都绑定到chart上了


    please verify my account

    2017年4月28日 9:49
  • 我已经debug好几遍了

    please verify my account

    2017年4月28日 9:49
  • Hi,

    >> 曲线是不同,但是数据量是相同的,x轴的数据相同, 都有数据返回,我都绑定到chart上了

    到目前为止,你的问题的根源还不知道,所以我建议你使用排除法,模拟服务器的数据并有规律的返回,看看会不会是多线程更新导致的问题,如果没有问题,那就是服务器返回的问题。

    Best regards

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月28日 9:59
  • 没有用多线程啊,

    服务器返回啥都不重要,最重的是我的三个chart控件数据曲线显示不同步,第三个快,还是一点一点的刷新,



    please verify my account

    2017年4月28日 10:03
  • 服务器给我一包数据,我解析成三个data,绑定到三个chart,但是显示的有快有慢,我都是一起显示的

    please verify my account

    2017年4月28日 10:04
  • 找到原因了,

         OnDataChanged(new DataChangedEventArgs(list1, list22, list33));
                            await Task.Delay(200);
                            if (stream != null)
                                //再次请求数据
                                await stream.WriteAsync(ResSuccess(), 0, ResSuccess().Length);
    我加上
     await Task.Delay(200);
    chart刷新速度就差不多了,请问这怎么修改?



    please verify my account

    2017年4月28日 10:37
  • Hi,

    我猜测可能是因为异步更新的速率太快导致UI界面反应不过来, 因为你的UI上有3个chart, 这三个chart是不可能达到同时更新的,因为UI线程是单线程, 你加上await Task.Delay(200) 实际上就是等待,延缓三个chart控件之间的更新间隔.

    可能的变通方案:

    1. 如你做的,延缓更新;

    2. 将三条数据放在一个chart控件里面

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2017年4月28日 11:03