I think window is to be activated after creating the Graph control.
Window can be activated in hidden mode. ACTIVATE WINDOW HIDDEN. I don't know if this helps.
#include "fivewin.ch"
#include "tgraph.ch"
function main()
local oWnd
define window oWnd title "Graph printing test"
activate window oWnd on init doIt()
return nil
function doIt()
local oWnd
define window oWnd
activate window oWnd on init doPie(oWnd)
return nil
function doPie(oWnd)
local oPie
local a:={},b:={}
local nWidth:=500, nHeight:=500
oWnd:hide()
aadd(a,1)
aadd(a,1)
aadd(b,20)
aadd(b,20)
oPie := TGraph():New( 0, 0, oWnd, nWidth, nHeight, .f., .t. )
with object oPie
:cTitle := "Malignancy % Found On Sample"
:cSubTit := alltrim( "Specimen" )
:AddSerie( { 14 },"Cancer %", RGB( 50, 50,200), GRAPH_TYPE_PIE, .t. )
:AddSerie( { 100.00 - 14 },"Non-Cancer", CLR_BLUE, GRAPH_TYPE_PIE, .t. )
end
PrintGraph( oPie, a[ 1 ], a[ 2 ], b[ 2 ] - a[ 2 ], b[ 1 ] - a[ 1 ] )
oPie:end()
oWnd:end()
return nil
FUNCTION PrintGraph(oGraph, nTop, nLeft, nWidth, nHeight)
LOCAL oPrn
PRINT oPrn NAME "Impresión de gráficos" //PREVIEW
oPrn:Cmtr2Pix(@nTop , @nLeft)
oPrn:Cmtr2Pix(@nWidth, @nHeight)
PAGE
oGraph:Print( oPrn, nTop, nLeft, nWidth, nHeight )
ENDPAGE
ENDPRINT
RETURN (NIL)
// eof
*--------------------------------------------------------------------------------------------------------------------------
METHOD PrintPieCharts() Class PathologyTranscription
local oPie
local oWnd
local a, b
local n := 1
local nLastLine := ::nLastLine - 1
local nWidthInInchs, nhrzFctr, nVrtFctr
DEFINE WINDOW oWnd FROM 0,0 to 1, 2
ACTIVATE WINDOW oWnd
::oSpcs:Seek( ::odbf:PathNo )
nhrzFctr := GetSysMetrics( 0 ) / GetDeviceCaps( ::oPrn:hDC, HORZRES )
nVrtFctr := GetSysMetrics( 1 ) / GetDeviceCaps( ::oPrn:hDC, VERTRES )
While !::oSpcs:eof() .and. ::oSpcs:PathNo == ::odbf:PathNo
if ::oSpcs:Cancrprcnt > 0.00
nLastLine += 2.00
nWidthInInchs := Min( ::aColumnsCoords[ ::nCurrCol, 2 ] - ::aColumnsCoords[ ::nCurrCol, 1 ], 2 ) + 1
a := ::oprn:Inch2Pix( nLastLine, ::aColumnsCoords[ ::nCurrCol, 1 ] +1.25)
b := ::oPrn:Inch2Pix( nLastLine + 1.5, nWidthInInchs + 0.5)
oPie := TGraph():New( a[ 1 ] * nVrtFctr, a[ 2 ] * nhrzFctr, oWnd, ;
b[ 2 ] * nHrzFctr , b[ 2 ] * nVrtFctr )
With Object oPie
:lPopUp := .f.
:nType := GRAPH_TYPE_PIE
:l3D := .T.
:lLegends := .f.
:lViewVal := .f.
:lBorders := .t.
:AddSerie( { ::oSpcs:Cancrprcnt },"Cancer %", RGB( 50, 50,200), GRAPH_TYPE_PIE, .t. )
:AddSerie( { 100.00 - ::oSpcs:Cancrprcnt },"Non-Cancer", CLR_WHITE, GRAPH_TYPE_PIE, .t. )
End With
oPie:Print( ::oPrn, a[ 1 ], a[ 2 ], 0.00, 0.00 )
oPie:End()
a := ::oPrn:Inch2Pix( nLastLine - 1, ::aColumnsCoords[ ::nCurrCol, 1 ] )
b := ::oPrn:Inch2Pix( ::aColumnsCoords[ ::nCurrCol, 2 ], nLastLine - 1 )
::PrintSectionHdr( a, b,, Str( n, 2 ) + ")" + ;
ProperName( Alltrim( ::oSpcs:Specimen ) ), ::aFonts[ 13 ] )
::oPrn:InchSay( nLastLine + 0.25, ::aColumnsCoords[ ::nCurrCol, 1 ] + 0.25, ;
"Malignancy " + Transform( ::oSpcs:Cancrprcnt, "999.99%" ) + ;
iif( ::oSpcs:gleason_1 + ::oSpcs:gleason_2 > 0, ;
" Gleason Score: " + Str( ::oSpcs:Gleason_1 + ::oSpcs:Gleason_2, 2 ) +;
" (" + Str( ::oSpcs:Gleason_1 ) + "-" + Str( ::oSpcs:Gleason_2 ) + ") ", "" ), ;
::aFonts[ 1 ] )
::nMaxLineOnPage := Max( ::nMaxLineOnPage, nLastLine ) //used for placement of signature
if nLastLine + 1.5 > ::nbottom
nLastLine := ::nTop - 1
::nCurrCol++
if ::nCurrCol > ::nMaxCols
::nCurrCol := 1
::PrintFooter()
::oPrn:EndPage()
::oPrn:StartPage()
endif
endif
End
n++
::oSpcs:Skip()
End
if nLastLine == ::nLastLine - 1
::nLastLine := ::nTop
else
::nLastLine := nLastLine + 1 //units is in inches
endif
oWnd:End()
return Nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 94 guests