Charts in Visual Basic PDF Print E-mail
Written by J. Bijvoets   
Sunday, 31 January 2010 14:09

Charting in VB.Net

Drawing charts in Visual Basic can be quite easy. The easiest way is to use MS Charts. On MSDN Microsoft writes the following about MS Charts:

"Microsoft Chart Controls for .NET Framework provides rich data visualization for developers. Using the Chart controls, you can create ASP.NET pages or Windows Forms applications with simple, intuitive, and visually compelling charts for complex statistical or financial analysis. These controls are specifically designed for use with Microsoft Visual Studio 2008."

The documentation for the MS Charts framework can be downloaded here.


Download the MS Charts Framework for free on this page.

 

An impressive demonstration for the framework can also be downloaded on MSDN.

 

Usage of the MS Charts in a nutshell

Using the MS Charts framework is quite easy:

1. First you have to install the framework.

2. After installation you can import the framework in your Visual Basic Project with:

Imports System.Windows.Forms.DataVisualization.Charting

3. Define a Chart-object:

Dim MyChart As New Charting.Chart

4. Add one or more dataseries to the chart, define area's, set the ChartType (e.g. Bar, Pie, Line, Spline, etc. etc.)

5. Bind the dataseries of the chart to one or more tables in a Dataset.

6. Build the actual chart. I use the charts myself for drawing a bitmap:

Dim bmp As New Bitmap(w, h) 'Draw on a new bitmap with Height h and Width w

Dim myRectangle As New Drawing.Rectangle(0, 0, w, h) 'Define drawing size

MyChart.DrawToBitmap(bmp, myRectangle)

 

Last Updated on Sunday, 31 January 2010 14:45