Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to plot the data from the server in a GUI in client. I am getting the data from the server to the client on PC. What I am currently doing is getting the data to a text box and each text is put into a array and data is taken from the array and plot the graph.

Is there any other easy method I can follow ?

this is my current code.

private void rbch1_CheckedChanged(object sender, EventArgs e)
     {
         timer1.Start();
         chart1.Series[0].Points.Clear();
     }

private void Timer1_Tick(object sender, EventArgs e)
     {
         t1 += timer1.Interval;
         if (rbch1.Checked == true)
         {
             channelone = new Thread(ch1);
             channelone.Start();
         }
     }

public void ch1()
     {
         if (rbch2.Checked == false)
         {
             chart1.Invoke((MethodInvoker)(() => chart1.Series[1].Points.Clear()));
         }
         String ch1 = txtdata.Text; ;
         String[] ch1y = ch1.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
         for (int a = 1; a < ch1y.Length - 1; a++)
         {
             chart1.Invoke((MethodInvoker)(() => chart1.Series[0].Points.AddXY(t1, Convert.ToDouble(ch1y[a]))));
             chart1.Invoke((MethodInvoker)(() => chart1.ChartAreas[0].AxisX.Minimum = double.NaN));
             chart1.Invoke((MethodInvoker)(() => chart1.ChartAreas[0].AxisX.Maximum = double.NaN));
             if (chart1.Series[0].Points.Count > sampelsize())
                 chart1.Invoke((MethodInvoker)(() => chart1.Series[0].Points.RemoveAt(0)));
         }
      }


What I have tried:

I tried the above code and and able to plot. But I want to know is there any other easy method.
Posted
Updated 23-Aug-22 2:58am
Comments
[no name] 10-Mar-21 13:23pm    
You're joking. You're sweating a few lines that "work" and you want someone else to sweat it too? Or, you've left out some details.

1 solution

You can consider using list ofPointF to store data.
C#
using System.Drawing;

List<PointF> Datas = new List<PointF>();
Datas.Add(new PointF(<X>,<Y>));


Skip textbox, directly store incoming data to list.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900