Daya Daya

Daya Daya

  • 0
  • 4
  • 1.5k

Loading Datagrid view data into Live Chart for C# form app

Jan 30 2020 4:34 AM
I am using Live chart for the first time in a C# form application. I have a data grid view (datagridview1). It has two columns. Date and Price. I am trying to make a cartesian diagram based on these two values. I dunno how to use the data grid view column values in the chart. Any suggestions, please!
 
  1. cartesianChart1.Series = new SeriesCollection  
  2.             {  
  3.                 new LineSeries  
  4.                 {  
  5.                     Title = "Date Vs Price",                                         
  6.                 },  
  7.   
  8.             };  
  9. cartesianChart1.AxisX.Add(new Axis  
  10.             {  
  11.                 Title = "Date",  
  12.                 //values-- how to get Date values here  
  13.   
  14.             });  
  15. cartesianChart1.AxisY.Add(new Axis  
  16.             {  
  17.                 Title = "Price",  
  18.                 //values-- how to get price values here  
  19.   
  20.             });  
  1. //My data is in the following format  
  2. |Date                |Price     |  
  3. |2020-01-27 09:42:38 |100       |  
  4. |2020-01-27 09:43:38 |200       |  
  5. |2020-01-27 09:44:38 |220       |  

I am trying to draw a cartesian graph--> Date Vs. Price. Any suggestion to load these data into the live chart from Datagrid view?

Answers (2)