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'
