Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO EDIT DATA ON MSGRAPH 2000

Status
Not open for further replies.

remsor

Programmer
Nov 5, 2002
101
PH
Hello experts,

Anybody have tried to edit the data of MSGRAPH 2000..
Or any idea on how to make graph on VFP6 or 7.

thanks for any idea..
 
Look in the help file for MSGraph for explanations
of its object model.

Also, in either Word, Excel, Access, etc. open
the Visual Basic Editor, select Tools->References,
and select "Microsoft Graph x.x Object Library".
(where x.x is the version # on your system)

After that, select View->Object Browser and select
Graph in the top combobox of the now visible Object Browser.

You'll then be able to see the full type library for MSGraph.


Short example:

public oMsGraph
oMsGraph = CREATEOBJECT("MsGraph.Application")
oMsGraph.DisplayAlerts = .F.
oDataSheet = oMsGraph.Datasheet
oChart = oMsGraph.Chart

* Note: MsGraph's column and row indexes begin with 2
FOR x = 1 TO 10
FOR Y = 1 TO 10
oDataSheet.Cells(x+1,Y+1).VALUE = x*Y
NEXT
NEXT

oChart.HasTitle = .T.
oChart.ChartTitle.TEXT = "Hello MsGraph Chart World!"
oMsGraph.VISIBLE = .T.


'We all must do the hard bits so when we get bit we know where to bite' :)
 
A slight correction to my previous post.

* Note: MsGraph's column and row indexes begin with 2
should read MsGraph's data rows and columns begin with 2

Chart types are defined in the type library

Darrell

'We all must do the hard bits so when we get bit we know where to bite' :)
 
it did this in 99.
Its a bit of a nightmare.
You have to create a table with a general field.
Then bind the msgraph to the field, having set the parameters.

Yikes, just get a 3rd party graph lib.
trust me
 
Folks,

Thanks a lot, any other deeper idea is highly appreciated..
 
You can make a graph in VFP 7.0 Using the Graph Wizard. The wizard creates a .dbf with a "General" field containing the graph.

Michael
 
Here's a more extended example.

You can add a MSGraph object directly to
the form and avoid having to deal with its
UI as a separate entity.

Darrell


oForm = CREATEOBJECT("C_MSGraph2000")

oForm.SHOW()
READ EVENTS

DEFINE CLASS C_MSGraph2000 AS FORM
DOCREATE = .T.
AUTOCENTER = .T.
HEIGHT = 520
WIDTH = 593
CAPTION = "Using MSGraph 2000 plus"

*Note: Make sure to set the OleClass first
* or you'll crash VFP with a C000005!
ADD OBJECT oMsGraph AS OLECONTROL WITH ;
OLECLASS = "MSGraph.Chart.8", ;
TOP = 0, ;
LEFT = 0, ;
HEIGHT = 324, ;
WIDTH = 336, ;
NAME = "oMsGraph"

PROCEDURE INIT
WITH THIS
.oMsGraph.hasdatatable = .T.

* Get a reference to the graph's
* chart and the graph's datasheet
* via the application object of the chart
LOCAL oChart, oDataSheet

oChart = .oMsGraph.OBJECT
oDataSheet = oChart.PARENT.datasheet

oChart.HasTitle = .T.
oChart.ChartTitle.TEXT = "2002 Sales"

SELECT "graphdata"
GO TOP

* Add Column Headings
oDataSheet.cells(1,2) = "Qtr1 Sales"
oDataSheet.cells(1,3) = "Qtr2 Sales"
oDataSheet.cells(1,4) = "Qtr3 Sales"
oDataSheet.cells(1,5) = "Qtr4 Sales"

LOCAL lnGraphRow, lnGraphCol
lnGraphRow = 1
SCAN
lnGraphRow = lnGraphRow + 1
lnGraphCol = 0
FOR i = 1 TO 5
* Add the rows to the datasheet
oDataSheet.cells(lnGraphRow,lnGraphCol+i) = ;
EVAL("graphdata."+FIELD(i))
NEXT
ENDSCAN

oChart.AutoScaling = .F.
oChart.WIDTH = 500
.oMsGraph.STRETCH = 1 && Isometric view
.oMsGraph.WIDTH = 500
.oMsGraph.HEIGHT = 500

ENDWITH
ENDPROC


PROCEDURE LOAD
_VFP.AUTOYIELD = .F.

#DEFINE DATAPOINTS ;
"Mary,10000,20000,8000,34000;"+;
"John,12000,30000,1000,11000;"+;
"Beverly,900,2000,4000,8000;"+;
"Geoffrey,2000,3000,28000,44000;"+;
"Joyce,21000,24000,84000,34000"

CREATE CURSOR graphdata ( ;
salesperson c(10), ;
Qtr1Sales N(7), ;
Qtr2Sales N(7), ;
Qtr3Sales N(7), ;
Qtr4Sales N(7) )

lnRows = ALINES(laDataTable,STRTRAN(DATAPOINTS,";",CHR(13)))

FOR i = 1 TO lnRows
=ALINES(laRowData,STRTRAN(laDataTable[ i ],",",CHR(13)))

INSERT INTO graphdata ;
( ;
salesperson, ;
Qtr1Sales, ;
Qtr2Sales, ;
Qtr3Sales, ;
Qtr4Sales) ;
VALUES;
( ALLT(laRowData[1]), ;
INT(VAL(laRowData[2])), ;
INT(VAL(laRowData[3])), ;
INT(VAL(laRowData[4])), ;
INT(VAL(laRowData[5])) ;
)

NEXT
ENDPROC

PROCEDURE DESTROY
_VFP.AUTOYIELD = .T.
USE IN "graphdata"
CLEAR EVENT
ENDPROC

ENDDEFINE


'We all must do the hard bits so when we get bit we know where to bite' :)
 
darell,
thanks a lot with your answer.. one more question how about if i use the activex.. how do i passed my table to the data of the graph..
thanks..
 
You'll need to use the Copy to (filename) type xls.
Then use the .fileimport() method of the
ActiveX Application object.

Example:
[tt]
oForm = CREATEOBJECT("C_MSGraph2000")

oForm.SHOW()
READ EVENTS

DEFINE CLASS C_MSGraph2000 AS FORM
DOCREATE = .T.
AUTOCENTER = .T.
HEIGHT = 520
WIDTH = 593
CAPTION = "Using MSGraph 2000 plus"

*Note: Make sure to set the OleClass first
* or you'll crash VFP with a C000005!
ADD OBJECT oMsGraph AS OLECONTROL WITH ;
OLECLASS = "MSGraph.Chart.8", ;
TOP = 0, ;
LEFT = 0, ;
HEIGHT = 324, ;
WIDTH = 336, ;
NAME = "oMsGraph"

PROCEDURE INIT

CREATE CURSOR Sales (salesid N(2), customer c(10), saleamt N(5,2), qtr N(1))

INSERT INTO Sales (salesid,customer,saleamt, qtr) VALUES (2, "Mary", 200.33 ,1)
INSERT INTO Sales (salesid,customer,saleamt, qtr) VALUES (3, "John", 122.22, 3)
INSERT INTO Sales (salesid,customer,saleamt, qtr) VALUES (2, "Mary", 300.21, 2)
INSERT INTO Sales (salesid,customer,saleamt, qtr) VALUES (2, "Mary", 123.22, 4)
INSERT INTO Sales (salesid,customer,saleamt, qtr) VALUES (1, "Geoff", 324.22, 2)

COPY TO (ADDBS(SYS(2023))+"sales") TYPE XLS

WITH THIS
.oMsGraph.hasdatatable = .T.

* Get a reference to the graph's
* chart and the graph's datasheet
* via the application object of the chart
LOCAL oChart, oDataSheet

oAppObject = .oMsGraph.OBJECT.PARENT
oChart = .oMsGraph.OBJECT
oDataSheet = oChart.PARENT.datasheet

oChart.HasTitle = .T.
oChart.ChartTitle.TEXT = "Not quite right, but you get the idea!"+chr(13)+;
"You'll need to set the row values correctly in your table before exporting"+chr(13)+;
"Read the help file. "+chr(13)+"On my system it's :"+chr(13)+;
"C:\Program Files\Microsoft Office\Office10\1033\VBAGR10.CHM"

oAppObject.FileImport(ADDBS(SYS(2023))+"sales.xls")

oChart.AutoScaling = .F.
oChart.WIDTH = 500
.oMsGraph.STRETCH = 1 && Isometric view
.oMsGraph.WIDTH = 500
.oMsGraph.HEIGHT = 500

ENDWITH
ENDPROC

PROCEDURE LOAD
_VFP.AUTOYIELD = .F.
ENDPROC

PROCEDURE DESTROY
_VFP.AUTOYIELD = .T.
USE IN "Sales"
CLEAR EVENT
ENDPROC

ENDDEFINE
[/tt]

'We all must do the hard bits so when we get bit we know where to bite' :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top