I would forget MSGraph, it's slow. Use MSChart. It is simple and printable. ie: A quick sample (your picture control on report is file with expression: (getChart(CustomerID))
It shows up instantly (well when it does the myReport SQL) because graph drawing is pushed to "report form" and MSChart is fast.
*#INCLUDE "mschrt20.h"
#Define VtChChartType3dBar 0
#Define VtChChartType2dBar 1
#Define VtChChartType3dLine 2
#Define VtChChartType2dLine 3
#Define VtChChartType3dArea 4
#Define VtChChartType2dArea 5
#Define VtChChartType2dHorizontalBar 11
Set Safety Off
Select cust_id,emp_id,Sum(order_net) As totalSale;
FROM orders ;
GROUP By 1,2 ;
INTO Cursor empSales ;
nofilter
Select cs.cust_id As customerID,cs.Company, ;
emp.First_Name - (' '+emp.Last_Name) As employee,;
sl.totalSale ;
FROM empSales sl ;
INNER Join customer cs On cs.cust_id = sl.cust_id ;
INNER Join employee emp On emp.emp_id = sl.emp_id ;
ORDER By 1,3 ;
INTO Cursor myReport ;
nofilter
loCharter = Createobject('myCharter')
*MODIFY REPORT salescharting1
Report Form salescharting Prev
Procedure GetChart(tcCustomerID)
lcChartFile = Forcepath(Trim(m.tcCustomerID)+'.bmp',Sys(2023))
Local lcTemp
lcTemp = Forcepath(Sys(2015)+".tmp",Sys(2023))
lnRecno = Recno()
Copy Fields employee,totalSale ;
to (m.lcTemp) ;
for customerId==m.tcCustomerId ;
Type Delimited With "" With Tab
Go m.lnRecno
loCharter.Chart2Clipboard(Filetostr(m.lcTemp))
ClipBoard2BMP(m.lcChartfile)
Erase (m.lcTemp)
Return m.lcChartFile
Endproc
Procedure ClipBoard2BMP
Lparameters tcFileName
Local llResult,lcFileName
*
* Predefined Clipboard Formats
*
#Define CF_TEXT 1
#Define CF_BITMAP 2
#Define CF_METAFILEPICT 3
#Define CF_SYLK 4
#Define CF_DIF 5
#Define CF_TIFF 6
#Define CF_OEMTEXT 7
#Define CF_DIB 8
#Define CF_PALETTE 9
#Define CF_PENDATA 10
#Define CF_RIFF 11
#Define CF_WAVE 12
#Define CF_UNICODETEXT 13
#Define CF_ENHMETAFILE 14
#Define CF_HDROP 15
#Define CF_LOCALE 16
#Define CF_MAX 17
#Define CF_OWNERDISPLAY 0x0080
#Define CF_DSPTEXT 0x0081
#Define CF_DSPBITMAP 0x0082
#Define CF_DSPMETAFILEPICT 0x0083
#Define CF_DSPENHMETAFILE 0x008E
Declare short IsClipboardFormatAvailable In win32api Integer cbformat
Declare Integer GetClipboardData In win32api Integer uFormat
Declare Integer OpenClipboard In win32Api Integer hWndNewOwner
Declare Integer CloseClipboard In win32Api
Declare Integer SaveDIB In DibAPI32.Dll Integer hBitmap, String @ cFileName
Declare Integer GetSystemPalette In DibAPI32.Dll
lcFileName = Fullpath(Iif(Empty(m.tcFileName),;
PUTFILE("Save as Bitmap", 'FromClipBoard', "BMP"), ;
m.tcFileName))
If !Empty(m.lcFileName) And ( IsClipboardFormatAvailable(CF_DIB) # 0 )
OpenClipboard(0)
llResult = ( SaveDIB(GetClipboardData( CF_DIB ), @lcFileName) = 0)
CloseClipboard()
Endif
Return m.llResult
Endproc
Define Class myCharter As Form
Height = 400
Width = 700
Add Object Chart As OleControl With ;
Height = 400,Width = 700,OleClass="MSChart20Lib.MSChart.2"
Procedure Chart2Clipboard(tcData)
_Cliptext = m.tcData
With This.Chart
.Editpaste
.ChartType = VtChChartType2dBar
.SelectPart(1,1,1,1,1) && VtChPartTypePlot, index1, index2, index3, index4)
*!* Copy the chart to the clipboard in Windows Metafile format.
.repaint
.EditCopy
.ToDefaults()
Endwith
Endproc
Enddefine