>*** set the LOCALEID to English >nlLocaleId=sys(3004) && Save local id >=sys(3006,1033) && We will be sending instructions in English > >* Part of xlChartType constants >#DEFINE xl3DArea -4098 >#DEFINE xl3DColumn -4100 >#DEFINE xl3DLine -4101 >#DEFINE xl3DPie -4102 >#DEFINE xlArea 1 >#DEFINE xlBubble3DEffect 87 >#DEFINE xlLine 4 >#DEFINE xlPie 5 >#DEFINE xlRadar -4151 >#DEFINE xlSurface 83 > >#DEFINE TAB CHR(9) >#DEFINE CRLF CHR(13)+CHR(10) > > >CREATE cursor test (degree i, sine n(8,4) NULL, cosine n(8,4)) >FOR ix = 1 to 90 > INSERT into test ; > values ; > (ix,cos(ix)*ix,sin(ix)*ix) >ENDFOR >45 >SCAN next 30 && Nullify 30 degrees > REPLACE sine with .null. && Nullify some values to see effect >ENDSCAN > >WAIT window nowait "Filling cell values..." >MCGDATA = "" >nCols = fcount() >FOR ix = 1 to nCols > MCGDATA = MCGDATA + iif(empty(MCGDATA),"",TAB)+field(ix) >ENDFOR >MCGDATA = MCGDATA + CRLF >SCAN > FOR ix = 1 to nCols > MCGDATA = MCGDATA + iif(ix=1,"",TAB)+nvl(str(evaluate(field(ix))),"") > ENDFOR > MCGDATA = MCGDATA + CRLF >ENDSCAN >* Data prepare * > >CREATE cursor testgen (genfld1 g) >APPEND blank >APPEND general genfld1 class "msgraph" data MCGDATA >CREATE report testgraph from testgen >MESSAGEBOX("Pls add an OLEBoundControl to report that will be shown and size big enough." ; > +chr(13)+"Field name is [genfld1]") >MODI report testgraph >*** >* Now we have Graph object in gen field. (Graph8) >* Play with it > >oForm = createobject("Form") >WITH oForm > .height = 400 > .width = 600 > .show > .closable = .f. > .addobject("myGraph","OleBoundControl") > .addobject("myQuit1","myQuit") > .addobject("myChanger1","myDataChanger") > .addobject("myChanger2","myTypeChanger") > .addobject("myReport1","myReport") > WITH .myGraph > .height = oForm.height - 20 > .width = oForm.width > .left = 0 > .top = 0 > .ControlSource = "testgen.Genfld1" > > .hasdatatable = .t. > .DataTable.HasBorderOutline = .T. > WITH .DataTable.font > .name = "Arial" > .size = 8 > ENDWITH > > WAIT window nowait "Plotting..." > .hastitle = .t. > .haslegend = .t. > .ChartTitle.caption = "This is chart title" > .ChartType=xl3DArea > .object.application.plotby = 2 > #DEFINE xlCategory 1 > #DEFINE xlValue 2 > #DEFINE xlSeriesAxis 3 > WITH .Axes(xlCategory) > .hastitle = .t. > WITH .AxisTitle > .Caption = "This is category title" > .Font.Name = "Arial" > .Font.Size = 10 > .Font.Bold = .t. > ENDWITH > ENDWITH > WITH .Axes(xlSeriesAxis) > .hastitle = .T. > WITH .AxisTitle > .Caption = "This is SeriesAxis title" > .Font.Size = 8 > .Font.Bold = .f. > .Orientation = 90 && Show 90 degrees rotated > ENDWITH > ENDWITH > WITH .Axes(xlValue) > .hastitle = .T. > WITH .AxisTitle > .Caption = "This is Value title" > .Font.Size = 10 > .Font.Bold = .f. > .Orientation = 90 && Show 90 degrees rotated - clockwise > ENDWITH > ENDWITH > WAIT clear > .ChartArea.copy() > .visible=.T. > ENDWITH > .myQuit1.visible = .t. > .myReport1.left = .myChanger2.left+.myChanger2.width + 5 > .myReport1.visible = .t. > .myChanger1.visible = .t. > .myChanger2.visible = .t. >ENDWITH >**** Set the LocaleId to the previous value >=sys(3006,val(nlLocaleId)) > >READ events > >DEFINE class myquit as commandbutton > Left=1 > Top=0 > AutoSize = .T. > Caption="Close" > PROCEDURE click > Release all > Clear events >ENDPROC >ENDDEFINE > >DEFINE class myDataChanger as commandbutton > Left=150 > Top=0 > AutoSize = .T. > Caption="Change some data" > PROCEDURE click > WAIT window nowait "Changing cell values..." > WITH thisform.myGraph.object.application.datasheet > SELECT test > SCAN > IF isnull(sine) > .Cells(recno()+1,2).Value = sin(recno())*recno() > ENDIF > ENDSCAN > ENDWITH > SELECT testgen > thisform.myGraph.doverb(-6) > WAIT clear >ENDPROC >ENDDEFINE > >DEFINE class myTypeChanger as commandbutton > Left=300 > Top=0 > AutoSize = .T. > Caption="Change Chart Type" > PROCEDURE click > thisform.myGraph.ChartType = xlBubble3DEffect > thisform.myGraph.doverb(-6) >ENDPROC >ENDDEFINE > >DEFINE class myreport as commandbutton > Left=1 > Top=0 > AutoSize = .T. > Caption="Report" > PROCEDURE click > * warning !!! - Testgraph prepared manually containing gen field and sized > MESSAGEBOX("If you changed graphtype click once to update."+chr(13)+"This is a quirk of MSGraph.") > REPORT form testgraph preview >ENDPROC >ENDDEFINEHaving all these on form doesn't mean you have to show it, just to have the graph ole ref via form (never tried directly adding graph object to _screen or createobject).