#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Chart from datagridview vb net


    Hi Ive been searching for a way to take the data that's been generated and inputted into a datagridview and then chart these on a line graph.

    Code:
    Time         Watts           Watts      etc...     etc....
    10:39:43.000   647.67999    653.30219    0.16    1065.2799
    10:49:43.000   647.67999    651.19995     0       1062.48
    10:59:43.000   649.04883    654.86664     0.19   1059.4399.......
    is there a good way to do this or should i have made a datatable and binded it to the chart (however you do that). any help is appreciated!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    153
    Rep Power
    5
    If you are getting this data from a Db Table, you can point the datatable as datasource for datagrid as well as you can bind it to the chart. Otherwise you can form these data as an array and bind to the chart
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by jameer
    If you are getting this data from a Db Table, you can point the datatable as datasource for datagrid as well as you can bind it to the chart. Otherwise you can form these data as an array and bind to the chart
    i've been trying to bind the datatable to the chart using methods like

    Code:
    Chart1.DataBindTable(table)
    and

    Code:
     Dim bs As BindingSource
            bs = New BindingSource(table)
            Chart1.DataSource = bs
            Chart1.Refresh()
    but have had no luck getting anything to show up on the chart. any ideas why?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2009
    Posts
    153
    Rep Power
    5
    One more option is you can loop through the entire data in the table and add them to the table with the AddXY

    chart1.Series["Series1"].Points.AddXY(Convert.ToDouble(dr[1]),Convert.ToDouble(dr[0]));
    chart1.Series["Series1"].Points[i++].AxisLabel = dr[2].ToString();

    Comments on this post

    • ttw agrees
    • Nykinum agrees
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by jameer
    One more option is you can loop through the entire data in the table and add them to the table with the AddXY

    chart1.Series["Series1"].Points.AddXY(Convert.ToDouble(dr[1]),Convert.ToDouble(dr[0]));
    chart1.Series["Series1"].Points[i++].AxisLabel = dr[2].ToString();
    Yeah that's what i'll do as a last resort. I've just seen everybody online saying "just bind the datatable to the chart and it will all appear" and that seems like the easiest way if i could get it to work....

    Thanks for the advice though
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0
    Thank you for your great content and it's helped me a lot.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0
    Hi, check your datagridview id property.

IMN logo majestic logo threadwatch logo seochat tools logo