One customer ask me if I can insert on a Services 's Report ( Fattura) a circolar graph statistic
as this
is there someone can help me to modify the tgraph class to understand how make it ?
#include "fivewin.ch"
function Main()
local oWnd, aChart := {}
local aVal := { 2500, 500, 1250, 200, 860 }
local aClr := { CLR_GREEN, CLR_HRED, CLR_HBLUE, CLR_YELLOW, CLR_MAGENTA }
aChart := MakeDnChart( aVal, aClr )
DEFINE WINDOW oWnd TITLE "FWH : DRAW SHAPES"
oWnd:nWidth := 800
oWnd:nHeight := 800
ACTIVATE WINDOW oWnd CENTERED ;
ON PAINT oWnd:DrawShapes( aChart, { 100, 100, 500, 500 } )
return nil
function MakeDnChart( aVal, aClr )
local aChart := {}
local aSweep := {}
local nTotal := 0
local n, nAngle := -90
AEval( aVal, { |n| nTotal += n } )
AEval( aVal, { |n| AAdd( aSweep, n / nTotal * 360 ) } )
for n := 1 to Len( aVal )
AAdd( aChart, { "PIE", aClr[ n ], 0, 1024, 1024, 0, 0, 1023, 1023, nAngle, aSweep[ n ] } )
nAngle += aSweep[ n ]
next
nAngle := -90
for n := 1 to Len( aVal )
AAdd( aChart, { "PIE", CLR_WHITE, 4, 1024, 1024, 0, 0, 1023-4, 1023-4, nAngle, aSweep[ n ] } )
nAngle += aSweep[ n ]
next
AAdd( aChart, { "ELLIPSE", CLR_WHITE, 0, 1024, 1024, 255, 255, 1023 - 255, 1023 - 255 } )
return aChart
nageswaragunupudi wrote:
- Code: Select all Expand view
AAdd( aChart, { "ELLIPSE", CLR_WHITE, 0, 1024, 1024, 255, 255, 1023 - 255, 1023 - 255 } )
Is there on my fwh last release ?
function PrintChart( aChart )
local oPrn
local hBmp
PRINT oPrn PREVIEW
PAGE
hBmp := FW_CreateBitmap( { 4096, 4096, aChart } )
@ 1, 1 PRINT TO oPrn IMAGE hBmp SIZE 2, 2 INCHES
DeleteObject( hBmp )
ENDPAGE
ENDPRINT
return nil
#include "fivewin.ch"
function Main()
local oWnd, aChart := {}
local aVal := { { 2500, 500, 1250, 200, 860 }, ;
{ 1800, 750, 1500, 300, 400 } }
local aClr := { CLR_GREEN, CLR_HRED, CLR_HBLUE, CLR_YELLOW, CLR_MAGENTA }
aChart := MakeDnChart( aVal, aClr )
DEFINE WINDOW oWnd TITLE "DOUGHTNUT CHART"
@ 10,10 BUTTON "PRINT" SIZE 100,30 PIXEL OF oWnd ACTION PrintChart( aChart )
oWnd:nWidth := 800
oWnd:nHeight := 800
ACTIVATE WINDOW oWnd CENTERED ;
ON PAINT oWnd:DrawShapes( aChart, { 100, 100, 500, 500 } )
return nil
function MakeDnChart( aVals, aClr )
local aVal, nSeries, nHt, aRect
local aChart := {}
local aSweep := {}
local nTotal := 0
local n, nAngle
nSeries := Len( aVals )
nHt := Int( 512 / ( nSeries + 1 ))
aRect := { 0, 0, 1024, 1024 }
for each aVal in aVals
nTotal := 0
aSweep := {}
AEval( aVal, { |n| nTotal += n } )
AEval( aVal, { |n| AAdd( aSweep, n / nTotal * 360 ) } )
nAngle := -90
for n := 1 to Len( aVal )
AAdd( aChart, { "PIE", aClr[ n ], 0, 1024, 1024, aRect[ 1 ], aRect[ 2 ], aRect[ 3 ], aRect[ 4 ], nAngle, aSweep[ n ] } )
nAngle += aSweep[ n ]
next
nAngle := -90
for n := 1 to Len( aVal )
AAdd( aChart, { "PIE", CLR_WHITE, 4, 1024, 1024, aRect[ 1 ] + 2, aRect[ 2 ] + 2, aRect[ 3 ] - 2, aRect[ 4 ] - 2, nAngle, aSweep[ n ] } )
nAngle += aSweep[ n ]
next
aRect[ 1 ] += nHt
aRect[ 2 ] += nHt
aRect[ 3 ] -= nHt
aRect[ 4 ] -= nHt
next
AAdd( aChart, { "ELLIPSE", CLR_WHITE, 0, 1024, 1024, aRect[ 1 ], aRect[ 2 ], aRect[ 3 ], aRect[ 4 ] } )
return aChart
function PrintChart( aChart )
local oPrn
local hBmp
PRINT oPrn PREVIEW
PAGE
hBmp := FW_CreateBitmap( { 4096, 4096, aChart } )
@ 1, 1 PRINT TO oPrn IMAGE hBmp SIZE 2, 2 INCHES
DeleteObject( hBmp )
ENDPAGE
ENDPRINT
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Carles and 116 guests