dynamic pie chart on a resource dialog

dynamic pie chart on a resource dialog

Postby reinaldocrespo » Wed Jun 02, 2010 6:21 pm

Hi.

I need to show a pie chart on a dialog along with other controls. One of the controls on the dialog is a get where the user can input a %. A pie chart with that % covered with some color should then be drawn on the dialog.

I saw Tim Stone's work using RMChart and it looks like it should work, but there are no samples using resources on a fw dialog.

Below is a link to a similar dialog done with on access:

http://ssfl.dynalias.com/utilities/img-526151025-0001.pdf

Can someone point me in the right direction?


Thank you,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: dynamic pie chart on a resource dialog

Postby mmercado » Wed Jun 02, 2010 7:51 pm

Dear Reinaldo:
reinaldocrespo wrote:Can someone point me in the right direction?

Here you are a working sample kindly provided by Alfredo Arteaga:
Code: Select all  Expand view
// Program : Test en dialogos
// Author  : Alfredo Arteaga
// 23/03/2008

/*

    Nuevos parámetros para poder mezclar tipo de gráfico por serie

    oGraph:AddSerie( aVals, cLegend, nColor, nType, l3D )

*/


#Include "Fivewin.Ch"
#Include "TGraph.Ch"

FUNCTION DlgTest()
   LOCAL oDlg, oFont, oGraph1, oGraph2
   LOCAL aPers
   aPers:={"Ene","Feb","Mar","Abr","May","Jun","Jul"}

   DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-10
   DEFINE DIALOG oDlg RESOURCE "TG_Test" FONT oFont

   oGraph1 := TGraph():ReDefine(100,oDlg)

   With Object oGraph1
      :nType   := GRAPH_TYPE_PIE
      :l3D     := .T.
      :lPopUp  := .T.
      :lLegends:= .F.
      :nClrX   := CLR_WHITE
      :nClrY   := CLR_WHITE
      :nClrV   := CLR_WHITE
      :nMaxVal := 50
      :cBitmap := ".\Bacalar.Bmp"
      :AddSerie({-30,-20, 40, 15, 20,  5, 10},"Serie1",RGB(200, 50, 50),1,.T.)
      :AddSerie({ 10,  5, 20, 15, 40,-20,-30},"Serie2",RGB( 50, 50,200),3,.F.)
      :SetYVals(aPers)
   End With

   oGraph2 := TGraph():ReDefine(105,oDlg)

   With Object oGraph2
      :nType   := GRAPH_TYPE_BAR
      :l3D     := .F.
      :lPopUp  := .T.
      :lDegrade:= .T.
      :lLegends:= .F.
      :nMaxVal := 50
      :nMinVal :=-40
      :cBitmap := ".\Brush.Bmp"
      :AddSerie({-30,-20, 40, 15, 20,  5, 10},"Serie1",CLR_GREEN       ,2,.F.)
      :AddSerie({ 10,  5, 20, 15, 40,-20,-30},"Serie2",RGB(218,181, 28),1,.F.)
      :SetYVals(aPers)
   End With

   REDEFINE BUTTON ID 110 OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg
   oFont:End()

RETURN (NIL)
 


The RC:
Code: Select all  Expand view
/****************************************************************************


dlgtest.rc

produced by Borland Resource Workshop


*****************************************************************************/


LANGUAGE LANG_SPANISH,SUBLANG_SPANISH_MEXICAN


1 24 LOADONCALL MOVEABLE
{
 '3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31'
 '2E 30 22 20 65 6E 63 6F 64 69 6E 67 3D 22 55 54'
 '46 2D 38 22 20 73 74 61 6E 64 61 6C 6F 6E 65 3D'
 '22 79 65 73 22 3F 3E 0D 0A 3C 61 73 73 65 6D 62'
 '6C 79 20 78 6D 6C 6E 73 3D 22 75 72 6E 3A 73 63'
 '68 65 6D 61 73 2D 6D 69 63 72 6F 73 6F 66 74 2D'
 '63 6F 6D 3A 61 73 6D 2E 76 31 22 20 6D 61 6E 69'
 '66 65 73 74 56 65 72 73 69 6F 6E 3D 22 31 2E 30'
 '22 3E 0D 0A 3C 61 73 73 65 6D 62 6C 79 49 64 65'
 '6E 74 69 74 79 0D 0A 20 20 20 20 76 65 72 73 69'
 '6F 6E 3D 22 31 2E 30 2E 30 2E 30 22 0D 0A 20 20'
 '20 20 70 72 6F 63 65 73 73 6F 72 41 72 63 68 69'
 '74 65 63 74 75 72 65 3D 22 58 38 36 22 0D 0A 20'
 '20 20 20 6E 61 6D 65 3D 22 55 74 6F 70 69 61 50'
 '6C 61 6E 69 74 69 61 2E 4D 45 44 2E 4D 45 44 22'
 '0D 0A 20 20 20 20 74 79 70 65 3D 22 77 69 6E 33'
 '32 22 0D 0A 2F 3E 0D 0A 3C 64 65 73 63 72 69 70'
 '74 69 6F 6E 3E 59 6F 75 72 20 61 70 70 6C 69 63'
 '61 74 69 6F 6E 20 64 65 73 63 72 69 70 74 69 6F'
 '6E 20 68 65 72 65 2E 3C 2F 64 65 73 63 72 69 70'
 '74 69 6F 6E 3E 0D 0A 3C 64 65 70 65 6E 64 65 6E'
 '63 79 3E 0D 0A 20 20 20 20 3C 64 65 70 65 6E 64'
 '65 6E 74 41 73 73 65 6D 62 6C 79 3E 0D 0A 20 20'
 '20 20 20 20 20 20 3C 61 73 73 65 6D 62 6C 79 49'
 '64 65 6E 74 69 74 79 0D 0A 20 20 20 20 20 20 20'
 '20 20 20 20 20 74 79 70 65 3D 22 77 69 6E 33 32'
 '22 0D 0A 20 20 20 20 20 20 20 20 20 20 20 20 6E'
 '61 6D 65 3D 22 4D 69 63 72 6F 73 6F 66 74 2E 57'
 '69 6E 64 6F 77 73 2E 43 6F 6D 6D 6F 6E 2D 43 6F'
 '6E 74 72 6F 6C 73 22 0D 0A 20 20 20 20 20 20 20'
 '20 20 20 20 20 76 65 72 73 69 6F 6E 3D 22 36 2E'
 '30 2E 30 2E 30 22 0D 0A 20 20 20 20 20 20 20 20'
 '20 20 20 20 70 72 6F 63 65 73 73 6F 72 41 72 63'
 '68 69 74 65 63 74 75 72 65 3D 22 58 38 36 22 0D'
 '0A 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62'
 '6C 69 63 4B 65 79 54 6F 6B 65 6E 3D 22 36 35 39'
 '35 62 36 34 31 34 34 63 63 66 31 64 66 22 0D 0A'
 '20 20 20 20 20 20 20 20 20 20 20 20 6C 61 6E 67'
 '75 61 67 65 3D 22 2A 22 0D 0A 20 20 20 20 20 20'
 '20 20 2F 3E 0D 0A 20 20 20 20 3C 2F 64 65 70 65'
 '6E 64 65 6E 74 41 73 73 65 6D 62 6C 79 3E 0D 0A'
 '3C 2F 64 65 70 65 6E 64 65 6E 63 79 3E 0D 0A 3C'
 '2F 61 73 73 65 6D 62 6C 79 3E 0D 0A 0D 0A 0D 0A'
}


TG_TEST DIALOG 49, 91, 409, 194
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Distribución de saldos"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MEXICAN
{
 CONTROL "", 100, "TGraph", 0 | WS_CHILD | WS_VISIBLE, 5, 7, 196, 162
 CONTROL "", 105, "TGraph", 0 | WS_CHILD | WS_VISIBLE, 207, 7, 196, 162
 DEFPUSHBUTTON "&Salir", 110, 342, 174, 61, 14
 __CLASS "Button"
}
 

I sent it to your mail too, check it.

Best regards.

Manuel Mercado Gómez.
manuelmercado at prodigy dot net dot mx
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken and 75 guests