circolar grapphics

circolar grapphics

Postby Silvio.Falconi » Mon Mar 13, 2017 3:37 pm

One customer ask me if I can insert on a Services 's Report ( Fattura) a circolar graph statistic

as this

Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby nageswaragunupudi » Tue Mar 14, 2017 4:11 am

Code: Select all  Expand view

#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
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: circolar grapphics

Postby Silvio.Falconi » Tue Mar 14, 2017 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby Enrico Maria Giordano » Tue Mar 14, 2017 10:09 am

nageswaragunupudi wrote:
Code: Select all  Expand view
AAdd( aChart, { "ELLIPSE", CLR_WHITE, 0, 1024, 1024, 255, 255, 1023 - 255, 1023 - 255 } )


Great idea! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: circolar grapphics

Postby nageswaragunupudi » Tue Mar 14, 2017 11:54 am

Is there on my fwh last release ?

Avaliable from FWH 15.12 onwards.

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: circolar grapphics

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby Silvio.Falconi » Tue Mar 14, 2017 2:10 pm

Mister Rao,
Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby Silvio.Falconi » Tue Mar 14, 2017 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: circolar grapphics (DOUGHNUT CHARTS)

Postby nageswaragunupudi » Wed Mar 15, 2017 1:10 am

Another sample showing Doughnut Charts with multiple series.
Code: Select all  Expand view
#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
 


Image4
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: circolar grapphics

Postby Silvio.Falconi » Wed Mar 15, 2017 9:35 am

RAO ...Nice it!!
Is possible insert the values of each section and show the leggend as this ?
Image




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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby Silvio.Falconi » Wed Mar 15, 2017 3: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: circolar grapphics

Postby Silvio.Falconi » Fri Mar 17, 2017 4:23 pm

why not modify directly tgraph class ???
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 103 guests