Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Questions on grouping / coloring slices in pie charts

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Questions on grouping / coloring slices in pie charts
 Login/Join
 
Silver Member
posted
Hi,

I have created some pie charts and while they have come together I chose to go the route of editing the procedure file programmatically instead of the GUI as I found I was unable to get exactly what I wanted through the UI. I'd like to pose a few Q's and see what everyone thinks. Can this actually be achieved in the UI? If not, is it the best way?

1) Am I able to define the slices of the pie by a WHERE clause as opposed to a BY clause in the UI? I have done it in my procedure by something like the following. I didn't see a way to do this in the UI...

TABLE FILE Scores
PRINT
ID
COMPUTE Label /A20 = 'Low risk';
COMPUTE Group /I1 = 1;
WHERE Score LE 9;
ON TABLE HOLD AS HOLD_SCORES1
END

TABLE FILE Scores
PRINT
ID
COMPUTE Label /A20 = 'High risk';
COMPUTE Group /I1 = 2;
WHERE Score GE 10;
WHERE Score LE 15;
ON TABLE HOLD AS HOLD_SCORES2
END

TABLE FILE HOLD_SCORES1
PRINT *
BY LOWEST Group
ON TABLE HOLD AS SCORE_CHART
MORE
FILE HOLD_SCORES2
MORE
...
-RUN

GRAPH FILE SCORE_CHART
...

2) I came across a few examples of how to order the groups such that they are in the same order every time such that I can apply the appropriate color and control the appearance in the legend, (it seems to always go alphabetical). An example of this code is:

GRAPH FILE SCORE_CHART
SUM CNT.ID AS 'Count'
BY LOWEST Group NOPRINT
BY Label AS 'Category'

I couldn't get this to work in the legend, (just went to alphabetical). Thoughts on how this could be achieved? My other concern with the above approach is that I have upwards of 4 "groups" that could potentially be displayed in the chart, each with a specific assigned color. The problem I assume I will have is if say there is a 0 count for Group 3 and if I'm assigning the colors to the series, if my result set has only 3 series, the third series will get the fourth series' color.

Thanks for any advice!

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


Windows 8203 All output formats
 
Posts: 47 | Registered: November 30, 2018Report This Post
Virtuoso
posted Hide Post
If your Label field in -2- is defined the way it is in -1- it explain why it is ordered (in the legend) alphabetical : it's an alpha field.

Even if you have BUY LOWEST Group placed before, the graph will be ordered based on Group, but the legend, which is assigned based on Label field, will be ordered alphabetical.

A solution to always have the same colors to the same grouping is to code the possibilities, when they are limited.
But this need to have all combination defined which may be a pain. But you don't really need to have them all defined.

1- Determine which "slice" you will have and in which combination.
Using a technic such as you did with the MORE file you can easily know which hold file you have and which combination.
Let say that each letter is a slice that need a specific color.
The possibilities that you may need to manage are the following for 4 slices :
A-B-C-D
A-B-D
A-C-D
A-C
A-D
B-C-D
B-D
C-D
B
C
D
Everything possibilities that are in the A-B-C-D order such as A, A-B or A-B-C don't need specific condition to be applied.
2- Base on -1- you define color assignation section and have it include in your graph

Something as follow
GRAPH FILE SCORE_CHART
SUM CNT.ID AS 'Count'
BY LOWEST Group NOPRINT 
BY Label AS 'Category'
....
*GRAPH_SCRIPT
-IF &COLOR   EQ 'D'      THEN GOTO COLORD;
-IF &COLOR   EQ 'C'      THEN GOTO COLORC;
-IF &COLOR   EQ 'B'      THEN GOTO COLORB;
-IF &COLOR   EQ 'CD'     THEN GOTO COLORCD;
-IF &COLOR   EQ 'BD'     THEN GOTO COLORBD;
-IF &COLOR   EQ 'BCD'    THEN GOTO COLORBCD;
-IF &COLOR   EQ 'AD'     THEN GOTO COLORAD;
-IF &COLOR   EQ 'AC'     THEN GOTO COLORAC;
-IF &COLOR   EQ 'ACD'    THEN GOTO COLORACD;
-IF &COLOR   EQ 'ABD'    THEN GOTO COLORABD;
-GOTO COLORABCD

-COLORCD
setFillColor(getSeries(0),new Color(0,0,255));
setFillColor(getSeries(1),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORBD
setFillColor(getSeries(0),new Color(0,255,0));
setFillColor(getSeries(1),new Color(255,0,255));
-GOTO ENDCOLOR
-COLOBCD
setFillColor(getSeries(0),new Color(0,255,0));
setFillColor(getSeries(1),new Color(0,0,255));
setFillColor(getSeries(2),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORAD
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORAC
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(0,0,255));
-GOTO ENDCOLOR
-COLORACD
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(0,0,255));
setFillColor(getSeries(2),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORABD
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(0,255,0));
setFillColor(getSeries(2),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORB
setFillColor(getSeries(0),new Color(0,255,0));
-GOTO ENDCOLOR
-COLORAC
setFillColor(getSeries(0),new Color(0,0,255));
-GOTO ENDCOLOR
-COLORAD
setFillColor(getSeries(0),new Color(255,0,255));
-GOTO ENDCOLOR
-COLORABCD
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(0,255,0));
setFillColor(getSeries(2),new Color(0,0,255));
setFillColor(getSeries(3),new Color(255,0,255));

-ENDCOLOR
*END
ENDSTYLE
END


As for doing this in UI....don't even think about it


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Gold member
posted Hide Post
Hello Sean,
Here are two examples :

In the Bar graph you can control the order of legends by having an additional sort field with you sequence.
For fixing the colours I user conditional styling. It is bit of an over work but ensure that the colours are always fixed.

I was not able to control the legend order in Pie.

 -*IA_GRAPH_BEGIN

-*Do not delete or modify the comments above
-*********Bar***************************
ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET ARGRAPHENGINE=JSCHART
SET EMBEDHEADING=ON
SET GRAPHDEFAULT=OFF
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
DEFINE FILE CAR
COUNTRY_SORT/I2 = IF COUNTRY EQ 'ITALY' THEN 1 ELSE
				  IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE
				  IF COUNTRY EQ 'JAPAN' THEN 3 ELSE
				  IF COUNTRY EQ 'FRANCE' THEN 4 ELSE 5;
END

GRAPH FILE car
-* Created by Info Assist for Graph
SUM CAR.BODY.DEALER_COST
BY COUNTRY_SORT NOPRINT
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
WHERE CAR.ORIGIN.COUNTRY EQ &COUNTRY.(OR(FIND CAR.ORIGIN.COUNTRY IN CAR |FORMAT=A10,SORT=ASCENDING)).COUNTRY:.;
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET AUTOFIT ON
ON GRAPH SET UNITS &WF_STYLE_UNITS
ON GRAPH SET HAXIS &WF_STYLE_WIDTH
ON GRAPH SET VAXIS &WF_STYLE_HEIGHT
ON GRAPH SET LOOKGRAPH BAR
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
DEFMACRO=Condition_1, MACTYPE=RULE, WHEN=N2 EQ 'ENGLAND', $
DEFMACRO=Condition_2, MACTYPE=RULE, WHEN=N2 EQ 'ITALY', $
DEFMACRO=Condition_3, MACTYPE=RULE, WHEN=N2 EQ 'FRANCE', $
DEFMACRO=Condition_4, MACTYPE=RULE, WHEN=N2 EQ 'JAPAN', $
DEFMACRO=Condition_5, MACTYPE=RULE, WHEN=N2 EQ 'W GERMANY', $
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
TYPE=DATA, COLUMN=N2, BUCKET=color, $
TYPE=DATA, COLUMN=N3, BUCKET=x-axis, $
TYPE=DATA, COLUMN=N4, BUCKET=y-axis, $
TYPE=DATA, COLUMN=N4, MACRO=Condition_1, COLOR=RGB(255 0 0), HYPERLINK-COLOR=RGB(255 0 0), $
TYPE=DATA, COLUMN=N4, MACRO=Condition_2, COLOR=RGB(128 255 255), HYPERLINK-COLOR=RGB(128 255 255), $
TYPE=DATA, COLUMN=N4, MACRO=Condition_3, COLOR=RGB(128 0 64), HYPERLINK-COLOR=RGB(128 0 64), $
TYPE=DATA, COLUMN=N4, MACRO=Condition_4, COLOR=RGB(0 64 0), HYPERLINK-COLOR=RGB(0 64 0), $
TYPE=DATA, COLUMN=N4, MACRO=Condition_5, COLOR=RGB(64 0 128), HYPERLINK-COLOR=RGB(64 0 128), $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
*END
ENDSTYLE
END
-RUN

-*IA_GRAPH_FINISH 


-*********Pie***************************

ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET ARGRAPHENGINE=JSCHART
SET EMBEDHEADING=ON
SET GRAPHDEFAULT=OFF
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
-DEFAULTH &WF_TITLE='WebFOCUS Report';


GRAPH FILE car
-* Created by Info Assist for Graph
SUM CAR.BODY.DEALER_COST
BY CAR.ORIGIN.COUNTRY
WHERE CAR.ORIGIN.COUNTRY EQ &COUNTRY.(OR(FIND CAR.ORIGIN.COUNTRY IN CAR |FORMAT=A10,SORT=ASCENDING)).COUNTRY:.;
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET UNITS &WF_STYLE_UNITS
ON GRAPH SET HAXIS &WF_STYLE_WIDTH
ON GRAPH SET VAXIS &WF_STYLE_HEIGHT
ON GRAPH SET LOOKGRAPH PIE
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
setPieFeelerTextDisplay(1);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
DEFMACRO=Condition_1, MACTYPE=RULE, WHEN=N1 EQ 'ENGLAND', $
DEFMACRO=Condition_2, MACTYPE=RULE, WHEN=N1 EQ 'FRANCE', $
DEFMACRO=Condition_3, MACTYPE=RULE, WHEN=N1 EQ 'ITALY', $
DEFMACRO=Condition_4, MACTYPE=RULE, WHEN=N1 EQ 'JAPAN', $
DEFMACRO=Condition_5, MACTYPE=RULE, WHEN=N1 EQ 'W GERMANY', $
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
TYPE=DATA, COLUMN=N1, BUCKET=color, $
TYPE=DATA, COLUMN=N2, BUCKET=measure, $
TYPE=DATA, COLUMN=N2, MACRO=Condition_1, COLOR=RGB(0 128 255), HYPERLINK-COLOR=RGB(0 128 255), $
TYPE=DATA, COLUMN=N2, MACRO=Condition_2, COLOR=RGB(255 0 128), HYPERLINK-COLOR=RGB(255 0 128), $
TYPE=DATA, COLUMN=N2, MACRO=Condition_3, COLOR=RGB(255 255 0), HYPERLINK-COLOR=RGB(255 255 0), $
TYPE=DATA, COLUMN=N2, MACRO=Condition_4, COLOR=RGB(0 160 160), HYPERLINK-COLOR=RGB(0 160 160), $
TYPE=DATA, COLUMN=N2, MACRO=Condition_5, COLOR=RGB(255 128 0), HYPERLINK-COLOR=RGB(255 128 0), $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
*GRAPH_JS_FINAL
"pieProperties": {
    "holeSize": "0%"
},
"agnosticSettings": {
    "chartTypeFullName": "Pie_Multi"
}
*END
ENDSTYLE
END
-RUN

-*IA_GRAPH_FINISH
  


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
 
Posts: 74 | Location: UK | Registered: September 17, 2018Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Questions on grouping / coloring slices in pie charts

Copyright © 1996-2020 Information Builders