16.1.11

Chart Control VB.NET 2010

Hi Everybody,
I would like to explain one of faq within this essay , how can I can use chart control with VB.NET windows application? If any question, please feel free and contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

1-) We are creating a new Windows Application Project (chart_control1)



2-) We are designing this windows form in a similar way to bellowing picture



3-) Series Collection(Student)



4-) We are writing this code


Private Sub chart_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chart_btn.Click

Chart1.Series("Student").Points.AddXY("Jon", 10)
Chart1.Series("Student").Points.AddXY("Jordan", 30)
Chart1.Series("Student").Points.AddXY("Yen", 40)
Chart1.Series("Student").Points.AddXY("Nick", 20)

Chart1.Series("Student").ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar


End Sub


5-) Lets run application and click show button




6-) Change codes and run again

Private Sub chart_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chart_btn.Click

Chart1.Series("Student").Points.AddXY("Jon", 10)
Chart1.Series("Student").Points.AddXY("Jordan", 30)
Chart1.Series("Student").Points.AddXY("Yen", 40)
Chart1.Series("Student").Points.AddXY("Nick", 20)

Chart1.Series("Student").ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie


End Sub




7-) For 3D and run again

Private Sub chart_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chart_btn.Click

Chart1.Series("Student").Points.AddXY("Jon", 10)
Chart1.Series("Student").Points.AddXY("Jordan", 30)
Chart1.Series("Student").Points.AddXY("Yen", 40)
Chart1.Series("Student").Points.AddXY("Nick", 20)

Chart1.Series("Student").ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie

Chart1.Series("Student")("PieLabelStyle") = "Outside"

Chart1.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True




End Sub



33 comments:

  1. Useful tutorial

    Syed Feroz Zainvi (writing from: www.crossroadsbyzainvi.blogspot.com)

    ReplyDelete
  2. very thank you nice tutorial

    ReplyDelete
  3. Very nice, it was extremely helpful for me.
    It would be nice though if you could an example of how to show Percentages in addition to the X-axis labels

    ReplyDelete
  4. thank you very much. very helpful for me

    ReplyDelete
  5. wow ..very ease and very helpfull.. saved my lots of time and efforts...Thank you

    ReplyDelete
  6. U are really amazing person, are you MVP?

    Thanks

    ReplyDelete
  7. thnx for this :D
    anyways
    how to clear this? i mean what if i double click the button the chart will do it again. some sort of code to prevent doing that ? like .clear?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  8. u should control double click events ,
    and put to code under just button click event, not double click.

    regards,

    ReplyDelete
  9. Excellent. Do you have any example of how to graph financial data(stock)?

    ReplyDelete
  10. @Robert Pantino to clear the chart u have to clear the datasource and chartseries like

    Chart1.DataSource = Nothing
    Chart1.Series.Clear()

    or try only

    Chart1.Series.Clear()

    ReplyDelete
  11. @anonymous reply to robert pantino

    It wont work either :(

    ReplyDelete
  12. Great = )

    Roger

    ReplyDelete
  13. Well laid out tutorial and very helpful. Thanks.

    Andrew

    ReplyDelete
  14. Nice tutorial!
    thanks so much :)

    ReplyDelete
  15. Chart1.Series.Clear()
    Chart1.Series.Add("Student")
    Chart1.Series("Student").Points.AddXY("Jon", 10)
    Chart1.Series("Student").Points.AddXY("Jordan", 30)
    Chart1.Series("Student").Points.AddXY("Yen", 40)
    Chart1.Series("Student").Points.AddXY("Nick", 20)

    Chart1.Series("Student").ChartType =
    System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column

    Chart1.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True

    That works better too

    ReplyDelete
  16. greate!!you saved my day

    ReplyDelete
  17. Thanks very nice tuto

    ReplyDelete
  18. what is code for button on showing??

    ReplyDelete
  19. sorry crib made ​​thanks to create charts thank you toturial? love you

    ReplyDelete
  20. Great tutorial. Can you help me out in plotting x-y scatter point graph? I am quite new to vb 2010. Any help will be greatly appreciated. Thank You.

    ReplyDelete
  21. Hi Yener it is amazing all your knowledge and the way that you're sharing it, i would like to know if you have some example about charts but from SQL Server.

    Best Regards

    ReplyDelete
  22. You can Change the Color with this

    Chart1.Series("Student").Points(0).Color = Color.Gold 'Color for Jon
    Chart1.Series("Student").Points(1).Color = Color.Blue 'Color for Jordan
    Chart1.Series("Student").Points(2).Color = Color.LawnGreen 'Color for Yen
    Chart1.Series("Student").Points(3).Color = Color.Yellow 'Color for Nick

    ReplyDelete
  23. Thanks a million times for this source code

    ReplyDelete
  24. Thank you very much..we are pleased

    ReplyDelete
  25. How can I set the maximum name of student to display all their names? Coz when I add more than 8 it alternately display the names.

    TIA

    ReplyDelete
  26. Thanks, a tutorial fast and accurate

    ReplyDelete
  27. thank you for tutorial...

    how when the case net framework 2.0, I've tried the "Series" but still can not open the Chart tool

    ReplyDelete
  28. Cool staff. I learned this:Chart1.Series("Student")("PieLabelStyle") = "Outside"
    Placing labels outside. Thanks for early tutorial.
    How about extracting set of values entered by the user from textbox. Check if this is helpful http://mujaducator.blogspot.com/

    ReplyDelete