FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour circolar grapphics
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
circolar grapphics
Posted: Mon Mar 13, 2017 03:37 PM
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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 04:11 AM
Code (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 08:17 AM
Wonderful great Maestro

Is there on my fwh last release ?
it run also on Tprinter class I must draw it on an Invoice (Factura)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 10:09 AM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
AAdd( aChart, { "ELLIPSE", CLR_WHITE, 0, 1024, 1024, 255, 255, 1023 - 255, 1023 - 255 } )


Great idea! :-)

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 11:54 AM
Is there on my fwh last release ?

Avaliable from FWH 15.12 onwards.

Code (fw): Select all Collapse
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
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 12:46 PM

THANKS RAO!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 02:10 PM
Mister Rao,


I wish insert values sample " 20%" on each section on circle

and I wish write also on the center of each circle

How I can make it ?

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Tue Mar 14, 2017 05:10 PM

For the text on the center I resolved !!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: circolar grapphics
Posted: Wed Mar 15, 2017 12:28 AM

Sorry, I can not help with writing text on each individual pie.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: circolar grapphics (DOUGHNUT CHARTS)
Posted: Wed Mar 15, 2017 01:10 AM
Another sample showing Doughnut Charts with multiple series.
Code (fw): Select all Collapse
#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


4
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Wed Mar 15, 2017 09:35 AM
RAO ...Nice it!!
Is possible insert the values of each section and show the leggend as this ?





I explain I have an archive where I calc the movements for each month from Jan to Dec .. I can send it
I wish insert on each part the name of th emonth and the value / %
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Wed Mar 15, 2017 03:32 PM

Dear Nages,
a Question
If you make multiple series as you made

local aVal := { { 2500, 500, 1250, 200, 860 }, ; first serie
{ 1800, 750, 1500, 300, 400 } } second serie

you must the possibility to set also two different colors for each serie

for a sample :

I have a Family Budget application and I set for each category of entries and exits a different color

How I can modify it to have multiple colors series ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: circolar grapphics
Posted: Fri Mar 17, 2017 04:23 PM

why not modify directly tgraph class ???

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion