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 Comments

  1. Hood June 4, 2011
  2. betty barnes October 22, 2011
  3. NONNOI January 20, 2012
  4. interesting articles January 25, 2012
  5. Shaxboz June 26, 2012
  6. ALEXANDRA September 3, 2012
  7. Noha December 7, 2012
  8. Halinia January 5, 2013

Leave a Reply