Focal Point
[CLOSED] Sorting Pie Chart by Percent

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

June 25, 2019, 01:15 PM
Jay Ervin
[CLOSED] Sorting Pie Chart by Percent
Hello!

I'm having some difficulty sorting a pie chart by anything other than the BY field. Specifically, I'd like to sort by the percentage each piece occupies (so the largest piece, then second largest... down to the smallest).

For instance:
GRAPH FILE CAR
	HEADING CENTER
	"Model Count by Make"
	SUM CNT.MODEL
	BY CAR
	ON GRAPH PCHOLD FORMAT JSCHART
	ON GRAPH SET LOOKGRAPH PIE
 
ON GRAPH SET STYLE *

*GRAPH_SCRIPT
setPieSorting(2);
setPieFeelerTextDisplay(1); 
*END

ENDSTYLE

END


I thought setPieSorting would address my need, but it doesn't seem to do anything. Is there a way to sort pie graphs by either percent or value?

Thanks!
Jay

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8.1/8.2, Windows 10/Server 2012
June 25, 2019, 01:20 PM
BabakNYC
  
GRAPH FILE ibisamp/car
SUM CNT.MODEL
BY TOTAL HIGHEST CNT.MODEL NOPRINT
BY CAR
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET LOOKGRAPH PIE
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT

setPieDepth(0);
setPieTilt(0);
setDepthRadius(0); 
setCurveFitEquationDisplay(false); 
setPlace(true); 
setPieFeelerTextDisplay(1); 

*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
TYPE=DATA, COLUMN=N1, BUCKET=color, $
TYPE=DATA, COLUMN=N2, BUCKET=color, $
TYPE=DATA, COLUMN=N3, BUCKET=measure, $
*GRAPH_SCRIPT

setReportParsingErrors(false);
setSelectionEnableMove(false);
*GRAPH_JS_FINAL
"pieProperties": {
"holeSize": "0%"
},
"agnosticSettings": {
"chartTypeFullName": "Pie_Pie"
}

*END
ENDSTYLE
END

-RUN



WebFOCUS 8206, Unix, Windows
June 25, 2019, 02:24 PM
Jay Ervin
Thank you for the response! I can't get your code to run as is, because Warm.sty isn't saved at that address as far as I can tell, and I can't find it. When I swap that style out with one I know works, I get a pie chart with 7 identically sized slices with a value of 1.

Any thoughts on what my app may be doing wrong in this?


WebFOCUS 8.1/8.2, Windows 10/Server 2012
June 25, 2019, 02:40 PM
BabakNYC
What version are you running? The code runs in my environment even when you comment out the style line. However, if you have InfoAssist, you should be able to create the same code in your version. Create a pie chart with CNT.MODEL as the measure and Color by CAR. Then right click CNT.MODEL in the query and click Sort, Descending. That ought to create a BY TOTAL CNT.MODEL NOPRINT in your code. See if that works.


WebFOCUS 8206, Unix, Windows
June 25, 2019, 02:42 PM
Jay Ervin
quote:
Originally posted by Jay Ervin:
Thank you for the response! I can't get your code to run as is, because Warm.sty isn't saved at that address as far as I can tell, and I can't find it. When I swap that style out with one I know works, I get a pie chart with 7 identically sized slices with a value of 1.

Any thoughts on what my app may be doing wrong in this?


Some more detail... I'm pretty sure the 7 pieces are the 7 car makes with only 1 model, so its excluding the 3 makes with 2+ models. The lines
TYPE=DATA, COLUMN=N1, BUCKET=color, $
TYPE=DATA, COLUMN=N2, BUCKET=color, $
TYPE=DATA, COLUMN=N3, BUCKET=measure, $

seems to enable/ disable 3 other pie charts, each with one car make, and each with a different model count.

Also, I'm working out of 8.1 if that makes a difference here.


WebFOCUS 8.1/8.2, Windows 10/Server 2012
June 25, 2019, 02:44 PM
BabakNYC
I don't believe BUCKET syntax existed in 8.1. If you have an 8.2 test environment, that's where this will work.


WebFOCUS 8206, Unix, Windows
June 25, 2019, 02:52 PM
Jay Ervin
I think I'm a few days away from our 8.2 DEV environment being up and running. I'll give it a try then.

Thanks for your help!


WebFOCUS 8.1/8.2, Windows 10/Server 2012