Guys:
If I'm displaying a 2 bar graph (sales & costs), how can I drop one series and repaint the graph using just one series, or vice-versa ? Thank you very much !!!
HunterEC wrote:Guys:
If I'm displaying a 2 bar graph (sales & costs), how can I drop one series and repaint the graph using just one series, or vice-versa ? Thank you very much !!!
#include "fivewin.ch"
#include "tgraph.ch"
REQUEST DBFCDX
function main()
local oDlg, oBrw, oGraph, oFont, nSeries
local aVals1 := {}
local aVals2 := {}
local n
CreateTestDBF() // Creates test DBF and opens with Alias "SC"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
// DEFINE DIALOG oDlg SIZE GetSysmetrics( 0 ) - 30, GetSysmetrics( 1 ) - 50 ;
// PIXEL FONT oFont ;
DEFINE DIALOG oDlg SIZE 950,350 PIXEL FONT oFont ;
TITLE "XBROWSE LINKED GRAPH"
@ 10,10 XBROWSE oBrw SIZE 210,160 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, ;
( nSeries := ALERT( "Data To Plot", { "Sales", "Costs", "Both" } ), ;
nSeries := IIF( nSeries == 0, 3, nSeries ) ), ReDoSeries( oGraph, nSeries ), ;
oGraph:Refresh() }
/*
:bChange := { || oGraph:cTitY := SC->MONTH, ;
oGraph:aData := {}, ;
aVals1 := { SC->USAS, SC->EUROS, SC->ASIAS }, ;
aVals2 := { SC->USAC, SC->EUROC, SC->ASIAC }, ;
AAdd( oGraph:aData, aVals1 ), ;
AAdd( oGraph:aData, aVals2 ), ;
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 250,160 PIXEL OF oDlg ;
TITLE "Sales and Costs" ;
XVALUES YVALUES TYPE GRAPH_TYPE_BAR LEGENDS
oGraph:cTitY := SC->MONTH
oGraph:l3D := .T.
aVals1 := { SC->USAS, SC->EUROS, SC->ASIAS }
aVals2 := { SC->USAC, SC->EUROC, SC->ASIAC }
ADD SERIE TO oGraph SERIE aVals1 LEGEND "Sales" COLOR CLR_HRED
ADD SERIE TO oGraph SERIE aVals2 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 }, ;
{ "APR", 1825, 1975, 1850, 675, 1100, 1425 }, ;
{ "MAY", 2000, 1670, 1550, 675, 1100, 1425 }, ;
{ "JUN", 0970, 1025, 1100, 675, 1100, 1425 }, ;
{ "JUL", 1150, 1600, 1750, 675, 1100, 1425 }, ;
{ "AUG", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "SEP", 1150, 1320, 1450, 675, 1100, 1425 }, ;
{ "OCT", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "NOV", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "DEC", 1250, 1700, 1850, 675, 1100, 1425 } ;
}
DBCREATE( "SALECOST.DBF", aCols, "DBFCDX", .T., "SC" )
FW_ArrayToDBF( aData )
GO TOP
return nil
//----------------------------------------------------------------------------//
function ReDOSeries ( oGraph, nSeries )
oGraph:aSeries := {}
oGraph:aData := {}
DO CASE
CASE nSeries == 1
ADD SERIE TO oGraph SERIE { SC->USAS, SC->EUROS, SC->ASIAS } LEGEND "Sales" COLOR CLR_HRED
CASE nSeries == 2
ADD SERIE TO oGraph SERIE { SC->USAC, SC->EUROC, SC->ASIAC } LEGEND "Costs" COLOR CLR_GREEN
CASE nSeries == 3
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
ENDCASE
return ( .T. )
//----------------------------------------------------------------------------//
#include "fivewin.ch"
#include "tgraph.ch"
REQUEST DBFCDX
function main()
local oDlg, oBrw, oGraph, oFont, nSeries
local aVals1 := {}
local aVals2 := {}
local n
CreateTestDBF() // Creates test DBF and opens with Alias "SC"
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
// DEFINE DIALOG oDlg SIZE GetSysmetrics( 0 ) - 30, GetSysmetrics( 1 ) - 50 ;
// PIXEL FONT oFont ;
DEFINE DIALOG oDlg SIZE 950,350 PIXEL FONT oFont ;
TITLE "XBROWSE LINKED GRAPH"
@ 10,10 XBROWSE oBrw SIZE 210,160 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 := {}, ;
aVals1 := { SC->USAS, SC->EUROS, SC->ASIAS }, ;
aVals2 := { SC->USAC, SC->EUROC, SC->ASIAC }, ;
AAdd( oGraph:aData, aVals1 ), ;
AAdd( oGraph:aData, aVals2 ), ;
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 250,160 PIXEL OF oDlg ;
TITLE "Sales and Costs" ;
XVALUES YVALUES TYPE GRAPH_TYPE_BAR LEGENDS
oGraph:cTitY := SC->MONTH
oGraph:l3D := .T.
aVals1 := { SC->USAS, SC->EUROS, SC->ASIAS }
aVals2 := { SC->USAC, SC->EUROC, SC->ASIAC }
ADD SERIE TO oGraph SERIE aVals1 LEGEND "Sales" COLOR CLR_HRED
ADD SERIE TO oGraph SERIE aVals2 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 }, ;
{ "APR", 1825, 1975, 1850, 675, 1100, 1425 }, ;
{ "MAY", 2000, 1670, 1550, 675, 1100, 1425 }, ;
{ "JUN", 0970, 1025, 1100, 675, 1100, 1425 }, ;
{ "JUL", 1150, 1600, 1750, 675, 1100, 1425 }, ;
{ "AUG", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "SEP", 1150, 1320, 1450, 675, 1100, 1425 }, ;
{ "OCT", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "NOV", 1250, 1700, 1850, 675, 1100, 1425 }, ;
{ "DEC", 1250, 1700, 1850, 675, 1100, 1425 } ;
}
DBCREATE( "SALECOST.DBF", aCols, "DBFCDX", .T., "SC" )
FW_ArrayToDBF( aData )
GO TOP
return nil
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 97 guests