none
Charts from datagridview in VB.Net

    Question

  • Good Day Gurus,

    How can I create charts in VB.Net Windows forms from a data present in datagridview?

    After creating charts I also want to provide a feature to save the chart to a file.

    Thanks,

    Srini

    Tuesday, November 19, 2013 7:45 AM

Answers

  • - I am using MS Chart control which comes in built with VS 2012

    - I am using Datagridview control which comes in built with VS 2012

    - I want to show the graph like pie chart/ bar chart on MS Chart control in my VB.Net application from the data present in datagridview (All are inbulit controls present in VS 2012)

    - Columns can be one or two but not more than that.

    Does this answer all of your questions ? Can you provide your solutions now ?

    Hi , your sentences points like i need the solution not you :) !! 

    here is the solution for a column chart , and of course you can change it to bar chart 

    Here i have added x Axis, y  Axis data from two columns of datagridview. 

        Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column         Chart1.Series(0).Points.Clear()         For Count AsInteger = 0To DataGridView2.Rows.Count - 2             Chart1.Series(0).Points.AddXY(DataGridView2.Item(0, Count).Value, DataGridView2.Item(1, Count).Value)         Next


      



    Satya R Biswal

    Tuesday, November 19, 2013 1:40 PM

All replies

  • Hi , Creating And saving  chart is fine , But what type of input you expect from Datagridview ?? 

    Do you want to show one column Data in chart ??

    What type of chart you want ??


    Satya R Biswal

    Tuesday, November 19, 2013 9:07 AM
  • From API programming I am adding a data to a datagridview and showing that data to the user. If user click on show graph button - chart control should be visible in a dialog form by taking data from datagridview.
    Tuesday, November 19, 2013 9:35 AM
  • Hi Srinivas, What type of chart you want ?? Eg Pie Chart , Bar Chart ???

    If i am not wrong ,suppose you have a datagridview with three columns . Lets say Col1, Col2, Col3 . When you hit chart button you want to display data from Col1 ( it may be from col2 or col3 , but not from all three columns ) .. 

    If no then how it is exactly describe !


    Satya R Biswal

    Tuesday, November 19, 2013 9:58 AM
  • I want to show a Bar chart.

    Yaa, data will be from only one column.


    Tuesday, November 19, 2013 10:09 AM
  • Hi ,

    What is the chart control you are using ?? or you need suggestion for any chart control ??


    Satya R Biswal

    Tuesday, November 19, 2013 10:11 AM
  • Hi ,

    What is the chart control you are using ?? or you need suggestion for any chart control ??


    Satya R Biswal

    Dear Satya R Biswal,

    If you don't know the answer just don't reply. Don't increase the thread by posting/asking useless questions.

    I want to create MS charts in VB.Net Windows form from a data present in datagridview? - If you know the solutions then share it else don't respond at all

    Tuesday, November 19, 2013 10:21 AM
  • The code to create chart from DataGridView data depends on the chart control you are using. If you are using Windows Form Chart Control then you can try following code

    Chart1.Series(SeriesIndex).Points.DataBindY(DataGridView1.DataSource, "ColumnName")

    You can also use DataPointCollection.AddXY Method

    http://msdn.microsoft.com/en-us/library/dd487988(v=vs.110).aspx


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor


    Tuesday, November 19, 2013 10:24 AM
  • The code to create chart from DataGridView data depends on the chart control you are using. If you are using Windows Form Chart Control then you can try following code

    Chart1.Series(SeriesIndex).Points.DataBindY(DataGridView1.DataSource, "ColumnName")

    You can also use DataPointCollection.AddXY Method

    http://msdn.microsoft.com/en-us/library/dd487988(v=vs.110).aspx


    Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor


    Can you give me any sample project for this ? I never created charts in VB.Net

    Thanks for your reply.

    Tuesday, November 19, 2013 10:46 AM
  • Hi Srinivas ,

    I would really appreciate if you answer all the related questions of my posts. 

    in First post you have written 

    "How can I create charts in VB.Net Windows forms from a data present in datagridview?"

    Do you think this is complete information you have provided to get an asnwer ?????

    And you have not mentioned from How many columns from datagridview you want to show the chart !

    It can be from Multiple columns ?? Right ???

    And What type of chart you want to show you have not mentioned ??? There are number of chart controls available for .NET . So you have not mentioned what type of control you are using and what type of chart you want to show !!!

    So when ever you are posting one question give enough information as well as all related information so that  answering process will be easy and of course with less number of threads !



    Satya R Biswal

    Tuesday, November 19, 2013 10:48 AM
  • - I am using MS Chart control which comes in built with VS 2012

    - I am using Datagridview control which comes in built with VS 2012

    - I want to show the graph like pie chart/ bar chart on MS Chart control in my VB.Net application from the data present in datagridview (All are inbulit controls present in VS 2012)

    - Columns can be one or two but not more than that.

    Does this answer all of your questions ? Can you provide your solutions now ?

    Tuesday, November 19, 2013 11:51 AM
  • - I am using MS Chart control which comes in built with VS 2012

    - I am using Datagridview control which comes in built with VS 2012

    - I want to show the graph like pie chart/ bar chart on MS Chart control in my VB.Net application from the data present in datagridview (All are inbulit controls present in VS 2012)

    - Columns can be one or two but not more than that.

    Does this answer all of your questions ? Can you provide your solutions now ?

    Hi , your sentences points like i need the solution not you :) !! 

    here is the solution for a column chart , and of course you can change it to bar chart 

    Here i have added x Axis, y  Axis data from two columns of datagridview. 

        Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column         Chart1.Series(0).Points.Clear()         For Count AsInteger = 0To DataGridView2.Rows.Count - 2             Chart1.Series(0).Points.AddXY(DataGridView2.Item(0, Count).Value, DataGridView2.Item(1, Count).Value)         Next


      



    Satya R Biswal

    Tuesday, November 19, 2013 1:40 PM
  • - I am using MS Chart control which comes in built with VS 2012

    - I am using Datagridview control which comes in built with VS 2012

    - I want to show the graph like pie chart/ bar chart on MS Chart control in my VB.Net application from the data present in datagridview (All are inbulit controls present in VS 2012)

    - Columns can be one or two but not more than that.

    Does this answer all of your questions ? Can you provide your solutions now ?

    Hi , your sentences points like i need the solution not you :) !! 

    here is the solution for a column chart , and of course you can change it to bar chart 

    Here i have added x Axis, y  Axis data from two columns of datagridview. 

        Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Column         Chart1.Series(0).Points.Clear()         For Count AsInteger = 0To DataGridView2.Rows.Count - 2             Chart1.Series(0).Points.AddXY(DataGridView2.Item(0, Count).Value, DataGridView2.Item(1, Count).Value)         Next


      



    Satya R Biswal

    Excellent.... This is what I was asking for....

    Thank you Satya and I did mean to be rude.... Sorry if any of my statement hurt you.

    Thank you so much

    Tuesday, November 19, 2013 2:07 PM