Page 1 of 1

Introduction to Graphs in VB.NET Using Microsoft Chart Control Rate Topic: ***** 1 Votes

#1 pe_mitev  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 74
  • Joined: 28-December 07

Post icon  Posted 29 December 2007 - 03:11 AM

Good moorning! I searched the VB.NET tutorials section and I didn't manage to find a tutorial showing the process of creating graphics in VB.NET and that's why I decided to write one. Let's begin

First, we have to create a new WindowsApplication
Attached Image

Now, we can see the form of the new project. Look at your Menus and Toobars section at the toolbar for this one: "Microsoft Chart Control, version 6.0 (OLEBG).

If you have it, skip the next two steps.

For those, who do not have it, add it how it is showed on the pictures.
Attached Image
On the the "Choose Toolbox items" dialog, click the second tab("Com components"), find the one showed on the picture and click ok.
Attached Image


Attached Image
Now, you must have it there. Grap one and stretch it on the form until you get the target size.


It is important to know basic attributes:
			.chartType 'Sets the type of graph. 
			'I will use the default one

			.Column 'We choose which of
			'the colums we will edit

			.ColumnCount 'Sets the number
			'Columns(Graphs) 

			.ColumnLabel 'Sets the caption
			'of the column
			'Default: C & column number

			.Data 'The most important field
			'it contains the value of 
			'the column

			'Rows are used to specify
			'in which field "R2" for 
			'example we will manage graphs

			'The syntax is simillar
			'We have: Row, RowCount, RowLabel, 



Now, let's actually start coding:

1. First I want to create 5 rows, with two columns(graphs).


Public Class Form1

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		'First Step
		AxMSChart1.RowCount = 5
		AxMSChart1.ColumnCount = 2


	End Sub
End Class



2. Let's improve point one and create a loop to understand how basic attributes work. The first graph's data I will multiply by 20 and the second, by 15.

Public Class Form1
 
	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Dim I As Integer

		'First Step
		AxMSChart1.RowCount = 5 'Specify count of rows to be 5
		AxMSChart1.ColumnCount = 2 'Specify count of graphs to be 2

		'the loop
		For I = 1 To AxMSChart1.RowCount 'Here it is dynamically and will work in all cases of values for AxMSChart1.Row

			'Set that we want to edit the row "I"
			AxMSChart1.Row = I

			'Setting it's label to I
			AxMSChart1.RowLabel = I

			'Editing the first graph
			AxMSChart1.Column = 1 'Set that I want to edit the second graph
			AxMSChart1.Data = I * 20

			'Editing the second Graph
			AxMSChart1.Column = 2 'Set that I want to edit the second graph
			AxMSChart1.Data = I * 15
		Next


	End Sub
End Class



It is important to know that you must have specified that ColumnCount is 2. If you have not done this, Visual Studio would return an error message.


Here is the result:
Attached Image

This is the way to work with Graphics. Feel free to change .chartType and the other attributes to understand better graphics.
You can also set your ShowLegend property to True and a legend will appear next to the graph.

If you have any questions, do not hesitate to ask here or via PM.

Is This A Good Question/Topic? 1
  • +

Replies To: Introduction to Graphs in VB.NET

#2 realwish  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 47
  • Joined: 29-January 08

Posted 23 June 2008 - 02:16 AM

but i want to implement a dynamic graph . i mean the real time application based graph which show the current activity
Was This Post Helpful? 0
  • +
  • -

#3 pe_mitev  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 74
  • Joined: 28-December 07

Posted 02 July 2008 - 10:06 AM

Sorry, I did not really get your question about the real based chart. I have not visited this forum for a while and I have not checked for new answers.
Was This Post Helpful? 0
  • +
  • -

#4 edirosadie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 11-January 07

Posted 07 June 2009 - 09:27 PM

hi,
nice post i looking for. but i got error which i can't identified when deploying to client computers. the error just showing error dialog box to send or not send to MS. the detail report consists :
P9 : System.InvalidOperationException
only one client, with office2000 while i use office 2003, successfully open the appliaction.

how to solve this problem?

thanks,
edi
Was This Post Helpful? 0
  • +
  • -

#5 edirosadie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 11-January 07

Posted 30 June 2009 - 09:42 PM

View Postedirosadie, on 7 Jun, 2009 - 08:27 PM, said:

hi,
nice post i looking for. but i got error which i can't identified when deploying to client computers. the error just showing error dialog box to send or not send to MS. the detail report consists :
P9 : System.InvalidOperationException
only one client, with office2000 while i use office 2003, successfully open the appliaction.

how to solve this problem?

thanks,
edi


this case solved; i have to copy the graph library to the client' computer.

edi
Was This Post Helpful? 0
  • +
  • -

#6 kamran85  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-September 09

Posted 07 September 2009 - 07:07 AM

Hi,

I am having to get it deployed on cliant computer. I have spent so muchtime on this but still class registeration failed.

Some one please help
Was This Post Helpful? 0
  • +
  • -

#7 Guest_Darshak*


Reputation:

Posted 23 April 2010 - 10:37 PM

I am working in Visual Basic .Net 2008 version,
I don't find this graph control when I click on Toolbox->Choose Items->COM components tab.

Is there any dll file to be added?
I can't find this control in the list.
Was This Post Helpful? 0

#8 slazhaja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-April 10

Posted 27 April 2010 - 12:04 PM

the code, same like in visual basic 6.0

if you want using chart for VB.Net 2008 you must download it before
Was This Post Helpful? 0
  • +
  • -

#9 kokhong  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-July 10

Posted 09 July 2010 - 08:38 PM

Hi,

i am newbie to vb 2008. And i have a project related to the dynamic data. The data may store in excel or access, and i will use visual basic to display graph for these data. Any idea to do it?
Was This Post Helpful? 0
  • +
  • -

#10 Fishhead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 10-August 10

Posted 10 August 2010 - 07:50 PM

I realize that the original post occurred a while ago, but there have been post this summer, so I hope I am not chasing a dead end.

I found the original post very helpful. I recently upgraded from vb.net 2003 to vb 2008 and wish to add some charts to my windows application. I have managed to incorporate a test chart in my porgram and it runs fine in debug mode, and if I build the application I can run it fine as a stand alone program on my computer, which is also the development computer.

However, when I attempted to run it on another computer I found that I needed to include a couple of dll files in the installation package. Namely axinterop.mschart20lib and interop.mschart20lib. That was easy to accomplish.

However, now I recieve an "Unhandled Exception" error. That says - "Class not registered(Exception from HRESULT:0x800154(REGDB_E_CLASSNOTREG)).

As with the missing dll files, the error notice appears when I click on a menu item that will load a form with the chart.

I followed the original example above. What is it that I still need to do to make this work properly?
Was This Post Helpful? 0
  • +
  • -

#11 anne052486  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 12-February 10

Posted 13 February 2011 - 12:20 AM

hello interesting,but can i create a chart using the datagrdview? or directly data from my database?
can u give me some hint
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1