all groups > dotnet interop > august 2005 >
You're in the

dotnet interop

group:

Using Msgraph directly in VB.NET application


Using Msgraph directly in VB.NET application Doudou
8/26/2005 1:10:44 AM
dotnet interop:
Hello,
First I'm french, so my english isn't very good.

I try to find explanation or example to use MsGraph object directly in
VB.NET application (in a windows form for example).

Is it possible ? Or is it necessary to use Office application (like
Excel) to use MsGraph object ?

Thanks for all response
Steph
Re: Using Msgraph directly in VB.NET application Mona
8/30/2005 12:00:00 AM
Hi Steph,

Regarding this issue of using the MS Chart directly in VB.Net application ,
I would like to tell you that first of all we need to add the MSChart
control in the toolbox. It will be in the Components Tab when you Add/Remove
the toolbox items.

Add an MS Chart control to a form and suppose the name of the Chart control
is Chart1, then we need to use the following snippet of code :

START CODE

Dim arrData(2, 2) As object

arrData(1, 1) = "Jan" ' Set the labels in the first series.

arrData(2, 1) = "Feb"

arrData(1, 2) = 8

arrData(2, 2) = 4

Chart1.ChartData = arrData



END CODE

Hope this helps.

Regards,
Mona [Grapecity]

[quoted text, click to view]

Re: Using Msgraph directly in VB.NET application udayt NO[at]SPAM microsoft.com
9/19/2005 5:58:40 AM
Thanks for Brief answer Mona,

Mona had given good example to use MS Chart which is a part of Office Web
Components on the VB.NET form.
The MS Chart has basic functionality of a displaying the chart. If you are
looking at something fancy then you can use the MS Graph on a WinForm.

All you have to do is,
(1) Add the reference of Microsoft Graph from the Add reference->COM tab
(2) The script will look something like,

Dim values(,) As Integer = {{1, 2, 3, 4}, _
{4, 5, 6, 7}, _
{7, 8, 9, 10}, _
{10, 11, 12, 14} _
}

Dim oGraph As New Graph.Global
Dim oDataSheet As Graph.DataSheet

oDataSheet = oGraph.Application.DataSheet

' Place headers into data table.
' Create four column headers.
oDataSheet.Cells(1, 2).Value = "Col1"
oDataSheet.Cells(1, 3).Value = "Col2"
oDataSheet.Cells(1, 4).Value = "Col3"
oDataSheet.Cells(1, 5).Value = "Col4"
' Create four row headers.
oDataSheet.Cells(2, 1).Value = "Row1"
oDataSheet.Cells(3, 1).Value = "Row2"
oDataSheet.Cells(4, 1).Value = "Row3"
oDataSheet.Cells(5, 1).Value = "Row4"

' Get four rows of data.
Dim lRowCnt, lColCnt As Integer
For lRowCnt = 2 To 5
For lColCnt = 2 To 5
oDataSheet.Cells(lRowCnt, lColCnt).Value = values(lRowCnt -
2, lColCnt - 2)
Next lColCnt
Next lRowCnt

Dim oChart As Graph.Chart
oChart = oGraph.Application.Chart

Dim oAxis As Graph.Axis
oAxis = oChart.Axes(Graph.XlAxisType.xlValue,
Graph.XlAxisGroup.xlPrimary)
oAxis.CrossesAt = 7

oChart.Export(FileName:="current_sales.gif", FilterName:="GIF")

oAxis = Nothing
oChart = Nothing
oDataSheet = Nothing

oGraph.Application.Quit()
oGraph = Nothing


For more information on Microsoft Graph object model, refer to,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbagr10/htm
l/grtocobjectmodelapplication.asp

I hope this information helps!

Regards,
Uday Takbhate [MSFT]
Microsoft Developer Support
--------------------
[quoted text, click to view]
AddThis Social Bookmark Button