Focal Point
[Solved]Remove 0% value from a PIE graph in PDF format

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9497050616

January 30, 2012, 09:17 AM
SriAravind
[Solved]Remove 0% value from a PIE graph in PDF format
I don't want to display 0% value for a Pie graph in PDF format.
Suppose if one value is 95%, another is 5% and last value is 0%, then i should display only the values of 95% and 5%. O% value should not get displayed in Pie graph.

But I'm getting 0% value in my pie graph. Suggest me some solution to ignore 0% value.

This message has been edited. Last edited by: SriAravind,


WebFocus Version 7.7.05
Windows, HTML/PDF/EXL2K/AHTML
January 30, 2012, 09:52 AM
Gary Gerstung
Try adding the statement:

WHERE TOTAL (name of % field) GT 0;
January 30, 2012, 03:41 PM
Waz
My guess is that its not 0, but 0.something.

How are you getting the percentage ?

Is it a calc, if so, is the amount zero ?, then remove it at that stage.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

January 31, 2012, 01:11 AM
SriAravind
WHERE TOTAL (name of % field) GT 0 is also not working.

Actually the value is not zero. But the % is showing as zero.

I'll give u similar sample code of the issue:

TABLE FILE CAR
SUM DEALER_COST AS 'DCOST'
BY CAR
WHERE CAR EQ 'BMW' OR 'JAGUAR'
END

RESULT:

CAR DCOST
----- -------
BMW 50000.000
JAGUAR 100.000

But while using the same for PIE graph, getting 0% for Jaguar and 100% for BMW
GRAPH FILE CAR
SUM DEALER_COST AS 'DCOST'
BY CAR
WHERE CAR EQ 'BMW' OR 'JAGUAR'
HEADING CENTER
"CAR SAMPLE GRAPH"
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 200
ON GRAPH SET VAXIS 200
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH PIESINGL
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 0
ON GRAPH SET GRAPHSTYLE *
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDepthRadius(5);
setTransparentBorderColor(getSeries(0),true);
setTransparentBorderColor(getSeries(1),true);
setTransparentBorderColor(getSeries(2),true);
setTransparentBorderColor(getSeries(3),true);
setTransparentBorderColor(getSeries(4),true);
setTransparentBorderColor(getSeries(5),true);
setTransparentBorderColor(getSeries(6),true);
setTransparentBorderColor(getSeries(7),true);
setTransparentBorderColor(getSeries(8),true);
setTransparentBorderColor(getSeries(9),true);
setTransparentBorderColor(getSeries(10),true);
setPieDepth(10);
setPlace(true);
setPieLabelDisplay(3);
setDisplay(getLegendArea(),false);
setOtherPieLabelDisplay(3);
setFontName(getTitle(),"SansSerif");
setFillColor(getTitle(),new Color(32,0,32));
setFontStyle(getTitle(),2);
setFontSizeAbsolute(getTitle(),true);
setFontSizeInPoints(getTitle(),10);
setPlaceResize(getTitle(),0);
setTextWrap(getPieLabel(),true);
setGradientDirection(getSeries(0),9);
setFillType(getSeries(0),1);
setFillColor(getSeries(1),new Color(66,102,179));
setFillColor(getSeries(2),new Color(211,203,79));
setFillColor(getSeries(3),new Color(78,143,109));
setFillColor(getSeries(4),new Color(214,130,40));
setFillColor(getSeries(5),new Color(164,120,90));
setFillColor(getSeries(6),new Color(191,68,62));
setFillColor(getSeries(7),new Color(153,102,51));
setFillColor(getSeries(8),new Color(145,165,65));
setFillColor(getSeries(9),new Color(95,160,160));
setFillColor(getSeries(10),new Color(176,96,140));

setFontSizeAbsolute(getPieSliceLabel(),true);
setFontSizeInPoints(getPieSliceLabel(),8);
setPlaceResize(getPieSliceLabel(),0);
setFontSizeAbsolute(getPieLabel(),true);
setFontSizeInPoints(getPieLabel(),8);
setPlaceResize(getPieLabel(),0);
setFillColor(getSeries(0),new Color(118,101,188));
setFontStyle(getPieSliceLabel(),0);
setFontStyle(getPieLabel(),0);
setTransparentBorderColor(getChartBackground(),false);
setPieFeelerTextDisplay(1);
setRect(getPieFrame(),new Rectangle(-15520.0,-13672.0,36373.0,26084.0));
setTextString(getSubtitle(),"\n\n\n");
setTextString(getTitle()," \n");
setDisplay(getTitle(),true);
ENDSTYLE
ON GRAPH SET STYLE *
TYPE=HEADING, LINE=1, ITEM=1, OBJECT=TEXT, SIZE=10, STYLE=BOLD, FONT='ARIAL', JUSTIFY=CENTER, $
ENDSTYLE
END


WebFocus Version 7.7.05
Windows, HTML/PDF/EXL2K/AHTML
January 31, 2012, 08:17 AM
njsden
I'm sure there should be a more "direct" way to get what you need but this may work for now.

DEFINE FILE CAR
DEAL/D12.2=IF CAR EQ 'DATSUN' THEN 100 ELSE DEALER_COST;
END
TABLE FILE CAR
SUM 
     CAR.BODY.DEAL
COMPUTE PCT_DEAL/I3% = PCT.CAR.BODY.DEAL;
BY  CAR.COMP.CAR
WHERE CAR EQ 'BMW' OR 'DATSUN' OR 'JAGUAR';
ON TABLE NOTOTAL
END


Will give you these results:



By HOLDing those results and excluding the one with 0% would give you:

DEFINE FILE CAR
DEAL/D12.2=IF CAR EQ 'DATSUN' THEN 100 ELSE DEALER_COST;
END
TABLE FILE CAR
SUM 
     CAR.BODY.DEAL
COMPUTE PCT_DEAL/I3% = PCT.CAR.BODY.DEAL;
BY  CAR.COMP.CAR
WHERE CAR EQ 'BMW' OR 'DATSUN' OR 'JAGUAR';
ON TABLE NOTOTAL
ON TABLE HOLD AS HDATA
ON TABLE SET ASNAMES ON
END
GRAPH FILE HDATA
SUM DEAL
BY CAR
WHERE PCT_DEAL GT 0
HEADING CENTER
"CAR SAMPLE GRAPH"
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 200
ON GRAPH SET VAXIS 200
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH PIESINGL
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 0
ON GRAPH SET GRAPHSTYLE *
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDepthRadius(5);
setTransparentBorderColor(getSeries(0),true);
setTransparentBorderColor(getSeries(1),true);
setTransparentBorderColor(getSeries(2),true);
setTransparentBorderColor(getSeries(3),true);
setTransparentBorderColor(getSeries(4),true);
setTransparentBorderColor(getSeries(5),true);
setTransparentBorderColor(getSeries(6),true);
setTransparentBorderColor(getSeries(7),true);
setTransparentBorderColor(getSeries(8),true);
setTransparentBorderColor(getSeries(9),true);
setTransparentBorderColor(getSeries(10),true);
setPieDepth(10);
setPlace(true);
setPieLabelDisplay(3);
setDisplay(getLegendArea(),false);
setOtherPieLabelDisplay(3);
setFontName(getTitle(),"SansSerif");
setFillColor(getTitle(),new Color(32,0,32));
setFontStyle(getTitle(),2);
setFontSizeAbsolute(getTitle(),true);
setFontSizeInPoints(getTitle(),10);
setPlaceResize(getTitle(),0);
setTextWrap(getPieLabel(),true);
setGradientDirection(getSeries(0),9);
setFillType(getSeries(0),1);
setFillColor(getSeries(1),new Color(66,102,179));
setFillColor(getSeries(2),new Color(211,203,79));
setFillColor(getSeries(3),new Color(78,143,109));
setFillColor(getSeries(4),new Color(214,130,40));
setFillColor(getSeries(5),new Color(164,120,90));
setFillColor(getSeries(6),new Color(191,68,62));
setFillColor(getSeries(7),new Color(153,102,51));
setFillColor(getSeries(8),new Color(145,165,65));
setFillColor(getSeries(9),new Color(95,160,160));
setFillColor(getSeries(10),new Color(176,96,140));

setFontSizeAbsolute(getPieSliceLabel(),true);
setFontSizeInPoints(getPieSliceLabel(),8);
setPlaceResize(getPieSliceLabel(),0);
setFontSizeAbsolute(getPieLabel(),true);
setFontSizeInPoints(getPieLabel(),8);
setPlaceResize(getPieLabel(),0);
setFillColor(getSeries(0),new Color(118,101,188));
setFontStyle(getPieSliceLabel(),0);
setFontStyle(getPieLabel(),0);
setTransparentBorderColor(getChartBackground(),false);
setPieFeelerTextDisplay(1);
setRect(getPieFrame(),new Rectangle(-15520.0,-13672.0,36373.0,26084.0));
setTextString(getSubtitle(),"\n\n\n");
setTextString(getTitle()," \n");
setDisplay(getTitle(),true);
ENDSTYLE
ON GRAPH SET STYLE *
TYPE=HEADING, LINE=1, ITEM=1, OBJECT=TEXT, SIZE=10, STYLE=BOLD, FONT='ARIAL', JUSTIFY=CENTER, $
ENDSTYLE
END






Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
January 31, 2012, 09:18 AM
SriAravind
Thanks njsden...ur code is working.Now i'm not getting 0% in graph.

But i need one clarification: My TABLE FILE request output retrieves two records one is 99% other is 0%. But on holding these values and displaying in graph it shows 100%.
How 99% from TABLE FILE request is changed to 100% in graph?


WebFocus Version 7.7.05
Windows, HTML/PDF/EXL2K/AHTML
January 31, 2012, 09:27 AM
njsden
Because you're not really plotting the 0% value anymore (the WHERE took that record out), so the remaining dealer cost you put in the pie chart now represents 100% of what's in the graph.

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
January 31, 2012, 09:40 AM
SriAravind
Appreciate ur help in providing a solution.Thanks


WebFocus Version 7.7.05
Windows, HTML/PDF/EXL2K/AHTML
January 31, 2012, 03:47 PM
Waz
I assume that you only want to show whole percentage amounts.

If you want more detail, then try adding this to the graph styling.
setPieFeelerTextFormat(3);


You will find that your example will show Jaguar (.2%) and BMW (99.8%)


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

January 31, 2012, 05:19 PM
Doug
Try:
WHERE TOTAL (name of % field) GE 1;

February 01, 2012, 01:43 AM
SriAravind
Waz...., setPieFeelerTextFormat(3) is also working. But i need % as a whole number only for my graph.

Doug..., WHERE TOTAL (name of % field) GE 1 is not working


WebFocus Version 7.7.05
Windows, HTML/PDF/EXL2K/AHTML
February 01, 2012, 03:24 PM
Waz
The reason WHERE TOTAL (name of % field) GE 1 is not working, is that the Graph is calculating the percentage.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!