February 03, 2006, 04:46 PM
MoogleGauge Graph (Type 110) - Controlling the Green/Yellow/Red bands
Hi Team,
I have a pretty good handle on hard-coding the Green/Yellow/Red "target" bands on the gauge graph. However, I am more interested in making these bands dynamic, based on data source fields.
For example, I want the needle to show yesterday's sales. The red band will start at zero (hardcoded) and then go to the sales for 1 year ago. The Green will start where the red stops and continue off the graph. I was also considering having yellow be some arbitrary amount between red and green.
The colour bands are controlled by the following commands:
setGaugeBandMin(getGaugeBand1(), 0);
setGaugeBandMax(getGaugeBand1(), 1000);
This example would start GaugeBand 1 at 0 and go to 1000.
I actually have a field that contains the SDLY Sales, so I tried this:
setGaugeBandMin(getGaugeBand1(), 0);
setGaugeBandMax(getGaugeBand1(), SALES_SDLY);
The output I get makes no sense, as Band 1 is red when I hardcode a number, but shows green when the field name is used. Furthermore, the value it is displaying is garbage; it starts at zero and goes to around 10 before stopping. This is the same behaviour that the chart defaults to before you edit the band ranges (red, yellow, green barely showing in the bottom left of the gauge).
I've tried populating variables with the -SET command to make them equal the SALES_SDLY field, and then putting the variable in the setGaugeBandMax field. Same strange behaviour. I know the variable passes correctly, since I can hardcode the variable's value in the set command and it behaves how it should. Seems like the graph just doesn't want me to use a field to control the bands.
Please help,
Joey
WF7.1, Tomcat on Linux, Informix on AIX
February 04, 2006, 08:03 AM
<JG>Joey,
I'm surprized that you got anything at all using a fieldname in the API code.
Take a look at the following example based on GGSALES.
SET HOLDLIST=PRINTONLY
DEFINE FILE GGSALES
YEAR/I4=EDIT(EDIT(EDIT(DATE),'9999'));
DOLLARSLY/I8=IF YEAR EQ 1996 THEN DOLLARS ELSE 0;
BUDDOLLARSLY/I8=IF YEAR EQ 1996 THEN BUDDOLLARS ELSE 0;
BUDDOLLARSTY/I8=IF YEAR EQ 1997 THEN BUDDOLLARS ELSE 0;
END
TABLE FILE GGSALES
SUM DOLLARSLY BUDDOLLARSLY BUDDOLLARSTY
BY REGION
WHERE YEAR EQ 1996 OR 1997
ON TABLE HOLD AS H1
END
-RUN
TABLE FILE H1
SUM AVE.DOLLARSLY NOPRINT
COMPUTE YELLOWMIN/I9= C1 * .8;
COMPUTE YELLOWMAX/I9= C1;
COMPUTE GREENMIN/I9=C1 * 1.1;
COMPUTE FULLD/D12.6=((AVE.BUDDOLLARSTY * 1.2)/1000000)+.5; NOPRINT
COMPUTE FULL/I9=INT(FULLD)*1000000;
ON TABLE HOLD AS VALUES FORMAT ALPHA
END
-RUN
-READ VALUES &YELLOWMIN.A9. &YELLOWMAX.A9. &GREENMIN.A9. &FULL.A9.
GRAPH FILE GGSALES
HEADING CENTER
"Regional Sales performance 1997 vs 1996"
SUM DOLLARS
ACROSS REGION
WHERE YEAR EQ 1997
ON GRAPH SET LOOKGRAPH GAUGE1
ON GRAPH SET GRAPHEDIT SERVER
ON GRAPH SET BARNUMB OFF
ON GRAPH SET 3D OFF
ON GRAPH SET VZERO ON
ON GRAPH SET GRID ON
ON GRAPH SET GRAPHSTYLE *
setScaleMaxAuto(false);
setScaleMax(getY1Axis(),&FULL.EVAL);
setGaugeBandMin(getGaugeBand1(), 0);
setGaugeBandMax(getGaugeBand1(), &YELLOWMIN.EVAL);
setGaugeBandMin(getGaugeBand2(), &YELLOWMIN.EVAL);
setGaugeBandMax(getGaugeBand2(), &YELLOWMAX.EVAL);
setGaugeBandMin(getGaugeBand3(), &YELLOWMAX.EVAL);
setGaugeBandMax(getGaugeBand3(), &GREENMIN.EVAL);
setGaugeBandMin(getGaugeBand4(), &GREENMIN.EVAL);
setGaugeBandMax(getGaugeBand4(), &FULL.EVAL);
setBorderColor(getGaugeBand1(),new Color(255,0,0));
setBorderColor(getGaugeBand2(),new Color(255,255,0));
setBorderColor(getGaugeBand3(),new Color(250,200,0));
setBorderColor(getGaugeBand4(),new Color(0,255,0));
setFillColor(getGaugeBand1(),new Color(255,0,0));
setFillColor(getGaugeBand2(),new Color(255,255,0));
setFillColor(getGaugeBand3(),new Color(250,200,0));
setFillColor(getGaugeBand4(),new Color(0,255,0));
setFontSizeAbsolute( getGaugeLabel(), true );
setFontSize( getGaugeLabel(), 9 );
setGaugeTitlePosition(3);
setSeriesLabel(0," ");
setPlace(false);
ENDSTYLE
END
JG
February 07, 2006, 09:45 AM
MoogleYou are my new hero!
This code example worked perfectly, for which I thank you big big.
Joey
March 08, 2006, 06:18 AM
kalyanswarnaHI JG
HOW CAN I CHANGE THE TICK VALUES FOR THIS .
AND I NEED TO TAKE THIS TICK VALUES FROM DATABASE.
THANKS
March 14, 2007, 12:40 PM
StephenHello - I have searched through the forum for 'Guage' topics. Can guage settings (like band definitions and label locations) be managed through the gui (report painter / graph assistant) ?