Creating Graph with VB.NET, Part 1: Basic Chart

This entry is part 1 of 3 in the series Creating Graph with VB.NET

This series shows how to create chart or graph with VB.NET using Microsoft Chart Controls for .NET Framework.

I divide the series into 3 parts:

  1. Creating Graph with VB.NET, Part 1: Basic Chart
  2. Creating Graph with VB.NET, Part 2: Customize Chart
  3. Creating Graph with VB.NET, Part 3: Data Binding Chart to Database

On this post, you will learn how to create a basic chart on Windows Form Application with VB.NET. I use Microsoft Visual Studio 2005 as IDE.

Requirement

Step-by-step to create basic chart on VB.NET

  1. Install the requirement software as stated on the Requirement section.
  2. Open Microsoft Visual Studio 2005. Create a new VB.NET’s Windows Application. Type the name of the project as “SampleBasicChart“.
    Create Windows Application's Project
  3. On Toolbox window, drag a Chart control from the Data category to the Windows Form.
    A Chart Control
    Note: If you does not see the Chart control in the Toolbox, you need to perform these steps below:

    • Right-click on the Toolbox window and select Choose Items.
      Add New Item to Toolbox
    • On Choose Toolbox Items, click Browse.
      Browse the Component
    • Browse to the location where you have installed Microsoft Chart Controls. The default location is
      C:\Program Files\Microsoft Chart Controls\Assemblies and select System.Windows.Forms.DataVisualization.dll. Then, click Open.
      System.Windows.Forms.DataVisualization.dll
    • You see Chart control has been added to .NET Framework Components. Verify that its check box is checked and click OK.
      Chat Control Component
  4. On Chart Properties, you see an empty chart with a default series, “Series1“. Next, I’m going to add another Series. On Chart Properties, click the Series collection. Then, click the ellipsis button.
    Chart Properties
  5. On Series Collection Editor, click Add. You will see “Series2” has been added to the collection.
    Series Collection Editor
  6. Now you have two series on a chart. But there is not any data on the chart so I will add some example data point on each series. Select Series1 and click the ellipsis button on Points collection.
  7. On Series Collection Editor, select “Series1” in the Members area and click the Points collection property. Then, click the ellipsis button.
    Add Data Points
  8. On DataPoint Collection Editor, click Add and assign a value “10” to the YValues property in the newly created DataPoint object.
    Set YValues on DataPoint
  9. Repeat step 8 to add two more DataPoint object with values “20” and “30” repectively. Then, click OK to close the DataPoint Collection Editor window.
    Note: These values are example values, you may use any value as you want.
  10. Repeat step 7-9 again on “Series2” with YValues as you want. Then, click OK to close the Series Collection Editor windows.
  11. Run the project. You see the chart with two series as you created.
    A Basic Chart
Series NavigationCreating Graph with VB.NET, Part 2: Customize Chart >>

8 Responses to “Creating Graph with VB.NET, Part 1: Basic Chart”

  1. ALEXANDRA

    Great website. Plenty of helpful info here. I am sending it to some buddies ans also sharing in delicious. And naturally, thank you to your effort!

  2. Noha

    This is very helpful..
    But I have a problem in this step:
    “Browse to the location where you have installed Microsoft Chart Controls. The default location is
    C:\Program Files\Microsoft Chart Controls\Assemblies and select System.Windows.Forms.DataVisualization.dll. Then, click Open.”
    I can’t find such a file…
    I appreciate if anyone tells me what to do… Thank you in advance !

  3. Halinia

    I have a problem when I “Browse to the location where you have installed Microsoft Chart Controls. The default location is
    C:\Program Files(86x)\Microsoft Chart Controls\Assemblies and select System.Windows.Forms.DataVisualization.dll. Then, click Open.”
    this toolbox is turn off and it does not work!!! how I can turn it on?
    Thanks

Comments are now closed for this article. If you still have issue and would like to discuss, you can post in the forum or send me a message.