Jack wrote:Hello,
I have a dialog with a Listbox and a Tgraph .
When i select an other line in the Listbox, i 'd like to repopulate the graph with the values of other records .
How to change the values of the graph ?
Thanks
#include "fivewin.ch"
#include "tgraph.ch"
REQUEST DBFCDX
function main()
local oDlg, oBrw, oGraph, oFont
CreateTestDBF() // Creates test DBF and opens with Alias "SC"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 900,340 PIXEL FONT oFont ;
TITLE "XBROWSE LINKED GRAPH"
@ 10,10 XBROWSE oBrw SIZE 210,150 PIXEL OF oDlg ;
DATASOURCE "SC" AUTOCOLS ;
HEADERS "MONTH", "USA", "EUROPE", "ASIA", "USA", "EUROPE", "ASIA" ;
FASTEDIT LINES NOBORDER
WITH OBJECT oBrw
:lHScroll := .f.
:lVScroll := .f.
:nStretchCol := 1
:nMarqueeStyle := MARQSTYLE_HIGHLROW
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:cEditPictures := "9,999"
:aCols[ 1 ]:cEditPicture := nil
:SetGroupHeader( "SALES", 2, 4 )
:SetGroupHeader( "COSTS", 5, 7 )
:bChange := { || oGraph:cTitY := SC->MONTH, ;
oGraph:aData := { { SC->USAS, SC->EUROS, SC->ASIAS }, ;
{ SC->USAC, SC->EUROC, SC->ASIAC } }, ;
oGraph:Refresh() }
AEval( :aCols, { |o| o:nEditType := EDIT_GET, ;
o:bOnChange := ;
{ |oc| oGraph:aData[ Int( ( oc:nCreationOrder - 2 ) / 3 ) + 1, ;
( oc:nCreationOrder - 2 ) % 3 + 1 ;
] := oc:Value, ;
oGraph:Refresh() } ;
}, 2 )
//
:CreateFromCode()
END
@ 10,220 GRAPH oGraph SIZE 200,150 PIXEL OF oDlg ;
TITLE "Sales and Costs" ;
XVALUES YVALUES TYPE GRAPH_TYPE_BAR LEGENDS
oGraph:cTitY := SC->MONTH
ADD SERIE TO oGraph SERIE { SC->USAS, SC->EUROS, SC->ASIAS } LEGEND "Sales" COLOR CLR_HRED
ADD SERIE TO oGraph SERIE { SC->USAC, SC->EUROC, SC->ASIAC } LEGEND "Costs" COLOR CLR_GREEN
SET Y LABELS OF oGraph TO { "USA", "EUROPE", "ASIA" }
oGraph:nMaxVal := 2000
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
static function CreateTestDBF()
local aCols := { ;
{ "MONTH", 'C', 3, 0 }, ;
{ "USAS", 'N', 4, 0 }, ;
{ "EUROS", 'N', 4, 0 }, ;
{ "ASIAS", 'N', 4, 0 }, ;
{ "USAC", 'N', 4, 0 }, ;
{ "EUROC", 'N', 4, 0 }, ;
{ "ASIAC", 'N', 4, 0 } }
local aData := { { "JAN", 1000, 1200, 900, 400, 700, 400 }, ;
{ "FEB", 1100, 1300, 1000, 500, 800, 500 }, ;
{ "MAR", 1050, 1800, 1900, 700, 1400, 1600 } ;
}
DBCREATE( "SALECOST.DBF", aCols, "DBFCDX", .t., "SC" )
FW_ArrayToDBF( aData )
GO TOP
return nil
:bChange := { || oGraph:cTitY := SC->MONTH, ;
oGraph:aData := { { SC->USAS, SC->EUROS, SC->ASIAS }, ;
{ SC->USAC, SC->EUROC, SC->ASIAC } }, ;
oGraph:Refresh() }
// Back area
//
IF ! Empty( ::cBitmap ) .AND. File( AnsiToOem( Lfn2Sfn( ::cBitmap ) ) )
::SayBitmap( 0, 0, AnsiToOem( Lfn2Sfn( ::cBitmap ) ), ::nWidth, ::nHeight )
ELSEIF Empty( ::oPrn ) .AND. ::nType != GRAPH_TYPE_PIE
IF ::nDegrade = 1
::FillRect( nTop, nLeft, nBottom-nDeep, nRight, ::nClrBack )
ELSE
hBru = GradientBrush( ::hDC, 0, 0, 0, nBottom-nDeep, ;
{ { 0, ::nClrBack, LightColor(175,::nClrBack) } }, .T. )
FillRect( ::hDC,{ nTop, nLeft, nBottom-nDeep , nRight }, hBru )
ENDIF
ENDIF
// Back area
//
IF ! Empty( ::cBitmap ) .AND. File( AnsiToOem( Lfn2Sfn( ::cBitmap ) ) )
::SayBitmap( 0, 0, AnsiToOem( Lfn2Sfn( ::cBitmap ) ), ::nWidth, ::nHeight )
IF ::nDegrade = 1
::FillRect( nTop, nLeft, nBottom-nDeep, nRight, ::nClrBack )
ELSE
hBru = GradientBrush( ::hDC, 0, 0, 0, nBottom-nDeep, ;
{ { 0, ::nClrBack, LightColor(175,::nClrBack) } }, .T. )
FillRect( ::hDC,{ nTop, nLeft, nBottom-nDeep , nRight }, hBru )
ENDIF
ELSEIF Empty( ::oPrn ) .AND. ::nType != GRAPH_TYPE_PIE
IF ::nDegrade = 1
::FillRect( nTop, nLeft, nBottom-nDeep, nRight, ::nClrBack )
ELSE
hBru = GradientBrush( ::hDC, 0, 0, 0, nBottom-nDeep, ;
{ { 0, ::nClrBack, LightColor(175,::nClrBack) } }, .T. )
FillRect( ::hDC,{ nTop, nLeft, nBottom-nDeep , nRight }, hBru )
ENDIF
ENDIF
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 15 guests