Click here to Skip to main content
15,894,254 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
public class VerticalForceGraph
    {
        private List<VerticalForce> vtfList = new List<VerticalForce>();

        public int BufferSize { get; set; }

        public void Add(VerticalForce vtf)
        {
            vtfList.Add(vtf);
        }

        public void Reset() { vtfList.Clear(); }

        public int Count {get{return vtfList.Count;} }

        public float[] GetLeftVTF()
        {
            return vtfList.Select(x => (float)x.Left).ToArray();
        }

private VerticalForceGraph vtfGraph = new VerticalForceGraph();

public void setVTFData(float[] frameValues)
        {
            if (vtfGraph != null)
            {
                vtfGraph.Add(new VerticalForce(frameValues));
            }
        }

//this is a panel in which i want to display line chart
private void VtfGraphicalViewMode(Graphics graphics)
       {


           Pen yellowPen = new Pen(Color.Yellow, 2);
           Pen bluePen = new Pen(Color.Blue, 2);
           Pen redPen = new Pen(Color.Red, 2);
           int hOffset = heatmapWidth / 2;
           int vOffset = heatmapHeight / 2;
           //Display title
           using (Font title_font = new Font("Times New Roman", 20))
           {

               using (StringFormat string_format = new StringFormat())
               {
                   string_format.Alignment = StringAlignment.Center;
                   string_format.LineAlignment = StringAlignment.Center;
                   Point title_center = new Point(this.heatmapWidth / 2, 20);
                   Point titleleft = new Point(this.heatmapHeight / 4, heatmapWidth / 10);


                   Font leftfornt = new Font("Times New Roman", 10);
                   Font totalfont = new Font("Times New Roman", 10);
                   Font rightfont = new Font("Times New Roman", 10);



                   graphics.SmoothingMode = SmoothingMode.AntiAlias;
                   graphics.DrawRectangle(outline, new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight));
                   Rectangle graph_area = new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight);
                   graphics.FillRectangle(Brushes.LightBlue, graph_area);
                   Label label = new Label();
                   graphics.DrawString("VTF Grahical View",
                          title_font, Brushes.Red,
                          title_center, string_format);



                   //Y-axis
                   int xOffset = 50;
                   int yOffset = 20;
                   graphics.DrawLine(redPen,
                                   heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50), heatmapCoord_X + xOffset, heatmapCoord_Y + yOffset
                                  );


                   //X-axis
                   graphics.DrawLine(redPen,
                                   heatmapCoord_X + (heatmapWidth - 10), heatmapCoord_Y + (heatmapHeight - 50), heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50)
                                  );


                   //MessageBox.Show(vtfGraph.Count.ToString());
                   if (vtfGraph.Count > 0)
                   {
                       float[] left = vtfGraph.GetLeftVTF(0, (vtfGraph.Count > 100 ? 100 : vtfGraph.Count - 1));

                       for (int i = 0; i < 100; i++)
                       {


                       }



                   }
               }
           }


What I have tried:

//left has array of values
//i want to plot these values in line graph
//i already defines x and y axis


float[] left = vtfGraph.GetLeftVTF(0, (vtfGraph.Count > 100 ? 100 : vtfGraph.Count - 1));
Posted
Updated 11-Sep-17 10:56am
v2
Comments
PIEBALDconsult 1-Sep-17 19:59pm    
Is this not the same question...
https://www.codeproject.com/Questions/1202562/How-do-I-draw-line-chart-in-Csharp
Member 13210933 5-Sep-17 11:34am    
Yes it is the same...because i am stuck up here so long :-( I am not getting how to draw live line chart from values which i have.
Member 13210933 5-Sep-17 11:36am    
Even no one understand my question :-( because i am not a good explainer.

1 solution

Here is my favourite [free] graphing library [with example source code]: Live Charts[^]
 
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