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.

New TIBCO Community Coming Soon
In early summer, TIBCO plans to launch a new community—with a new user experience, enhanced search, and expanded capabilities for member engagement with answers and discussions! In advance of that, the current myibi community will be retired on April 30. We will continue to provide updates here on both the retirement of myibi and the new community launch.

What You Need to Know about Our New Community
We value the wealth of knowledge and engagement shared by community members and hope the new community will continue cultivating networking, knowledge sharing, and discussion.

During the transition period, from April 20th until the new community is launched this summer, myibi users should access the TIBCO WebFOCUS page to engage.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Chart - Pie Slice Color tied to Series Name

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]Chart - Pie Slice Color tied to Series Name
 Login/Join
 
Member
posted
I am trying to get the color or my pie slices to appear the same based on the Series name. So for example if the slice is 'After 2pm', that slice should be red and if the slice is 'Before 9AM' the slice should be green. I formatted each of the series individually through App Studio but if there is 2 or less slices, the slices are not the correct color. It seems to be alphabetical, not linked to the series name. Does anyone know how to make this appear consistently, even if there is only one slice?
Thank you in advance!

This message has been edited. Last edited by: <Emily McAllister>,


WebFOCUS 8.2, Server 2008 R2, SQL 2014 data warehouse
 
Posts: 18 | Location: Daytona Beach | Registered: November 19, 2015Report This Post
Master
posted Hide Post
Hello Rosie, I live in St Augustine, so right down the road from ya. Welcome to FocalPoint!

I don't think there is a way to set color based on value for a pie chart. I usually set my colors based on the order of the pie, not the value with the use of:
setFillColor(getSeries(0),new Color(255,0,0));
setFillColor(getSeries(1),new Color(255,0,128));
setFillColor(getSeries(2),new Color(128,0,0));
setFillColor(getSeries(3),new Color(128,64,64));


However, you can order the data the way you need by the use of DECODE.

Example:
DEFINE FILE CAR ADD
MYSORT/A1=DECODE CAR.ORIGIN.COUNTRY ('JAPAN' 'a' 'ENGLAND' 'b' 'W GERMANY' 'c' 'ITALY' 'd');
END

ENGINE INT CACHE SET ON
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
GRAPH FILE CAR
-* Created by Info Assist for Graph
SUM CAR.BODY.SALES
BY MYSORT NOPRINT
BY CAR.ORIGIN.COUNTRY
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET UNITS &WF_STYLE_UNITS
ON GRAPH SET HAXIS &WF_STYLE_WIDTH
ON GRAPH SET VAXIS &WF_STYLE_HEIGHT
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 2
ON GRAPH SET LOOKGRAPH PIEMULTI
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/javaassist/intl/EN/ENIADefault_combine.sty,$
TYPE=REPORT, TITLETEXT='WebFOCUS Report', $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDisplay(getLegendArea(),false);
setPieFeelerTextDisplay(3);
setDisplay(getPieLabel(),false);
*END
ENDSTYLE
END



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Member
posted Hide Post
Hi! Nice to hear from a neighbor! Smiler Thanks for the welcome. The thing is, there may be 1 slice and up to 8 slices depending on how they are doing, so no order will accommodate for all the different possibilities to ensure the right color appears. I was hoping to have a visual representation of how we are doing so a larger green slice is good (since we want everyone to be before 9). Hmm


WebFOCUS 8.2, Server 2008 R2, SQL 2014 data warehouse
 
Posts: 18 | Location: Daytona Beach | Registered: November 19, 2015Report This Post
Expert
posted Hide Post
Hi Rosie,

I'll add my welcome to that from Gavin, although I am much further away!

The answer to your question, as Doug normally suggests, is "Yes, we can do that in WebFOCUS'.

I would add, that it depends on how much you want to stray from the GUI.

Using the ability to INCLUDE a file within any report or chart etc., you could extract the code that you need to colourise your series and INCLUDE it. The downside is that the GUI doesn't allow you to add an INCLUDE within the JSCHART script.

Anyhow, this sample code will demonstrate what I mean. Notice that I've used colour names, rgb values and hash values as the colours. The JSCHART engine permits any of these values.

TABLE FILE CAR
SUM SALES NOPRINT
    COMPUTE COLOUR/A16 = DECODE COUNTRY ('ENGLAND'   'rgb(0,142,126)'
                                         'FRANCE'    'yellow'
                                         'ITALY'     '#f00'
                                         'JAPAN'     '#0cccfc'
                                         'W GERMANY' 'rgb(173,204,189)' ELSE '#f00'); NOPRINT
-* Series numbering begins from 0 so the next two computes cater for this.
    COMPUTE COUNTER/I2  = IF SALES EQ 0 THEN LAST COUNTER ELSE LAST COUNTER + 1; NOPRINT
    COMPUTE SERIES/I2 = COUNTER - 1; NOPRINT
    COMPUTE SERIES_COLOUR/A50 = '{series:  '|LJUST(2,FPRINT(SERIES,'I2','A2'),'A2')||', color: '''||COLOUR||'''},';
BY COUNTRY NOPRINT
-* We only want data where the SUM.SALES ne 0
WHERE TOTAL SALES NE 0
-* Only hold the ouput that we need - exclude the NOPRINTs
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS seriesprops
END
-RUN

GRAPH FILE CAR
SUM SALES
BY COUNTRY
-* We only want data where the SUM.SALES ne 0 - to match the series properties extract
WHERE TOTAL SALES NE 0
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH PIEMULTI
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setPieFeelerTextDisplay(1);
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDisplay(getLegendArea(),false);
setPieFeelerTextDisplay(3);
setDisplay(getPieLabel(),false);
*END
TYPE=REPORT, TITLETEXT='Pie Chart - Custom Colours', $
*GRAPH_JS
series: [
-INCLUDE seriesprops.ftm
]
*END
ENDSTYLE
END


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
What is:

-INCLUDE seriesprops.ftm



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
The result of Step 1, programmatically creating the API code to be included in the GRAPH FILE step...
Very useful in maintaining continuity/uniformity, use it all the time....


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Gold member
posted Hide Post
Rosie
When it prompts for what_col type 2.
I keep the code in a separate fex so I can include it into multiple files keeping consistent colors throughout the code.

GRAPH FILE CAR
SUM
RETAIL_COST
BY COUNTRY
ON GRAPH PCHOLD FORMAT HTML
ON GRAPH SET PAGE-NUM NOLEAD
ON GRAPH SET EMPTYREPORT ON
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET ARGRAPHENGIN JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET GRMERGE OFF
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 3
ON GRAPH SET LOOKGRAPH PIE
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
PAGESIZE='Letter',$
DEFMACRO=COND0001,COLUMN=&WHAT_COL,MACTYPE=RULE,WHEN=COUNTRY EQ 'ENGLAND',$
DEFMACRO=COND0002,COLUMN=&WHAT_COL,MACTYPE=RULE,WHEN=COUNTRY EQ 'FRANCE',$
DEFMACRO=COND0003,COLUMN=&WHAT_COL,MACTYPE=RULE,WHEN=COUNTRY EQ 'GERMANY',$
DEFMACRO=COND0004,COLUMN=&WHAT_COL,MACTYPE=RULE,WHEN=COUNTRY EQ 'ITALY',$
DEFMACRO=COND0005,COLUMN=&WHAT_COL,MACTYPE=RULE,WHEN=COUNTRY EQ 'JAPAN',$
TYPE=DATA,COLOR=RGB(194 11 11),MACRO=COND0001,$
TYPE=DATA,COLOR=RGB(158 188 94),MACRO=COND0002,$
TYPE=DATA,COLOR=RGB(130 103 162),MACRO=COND0003,$
TYPE=DATA,COLOR=RGB(251 192 8),MACRO=COND0004,$
TYPE=DATA,COLOR=RGB(0 0 0),MACRO=COND0005,$
ENDSTYLE
END


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 74 | Registered: December 23, 2013Report This Post
Member
posted Hide Post
Thank you everyone!
J.L. It looks like your post has exactly what I am looking for! Although, I am pretty new to WebFOCUS so if you would be so kind as to pardon my amateur questions...
So in the example below, could I just copy the DEFMACRO= and TYPE= lines into mychart.fex (changing the colors and conditions appropriately)? Am I right in inferring that this example isn't looking to a separate fex for the formatting? And finally, where will it prompt me for what_col - it looks like it will be a report parameter? If that is the case, could I add a -SET in the code to keep it from prompting? This chart will be in a portal.
Thanks so much!


WebFOCUS 8.2, Server 2008 R2, SQL 2014 data warehouse
 
Posts: 18 | Location: Daytona Beach | Registered: November 19, 2015Report This Post
Master
posted Hide Post
quote:
where will it prompt me for what_col - it looks like it will be a report parameter?


You can replace the &WHAT_COL with RETAIL_COST and get the same results, without a prompt.

Something to note about Columns.. When it comes to what column number you looking at, start with "BY". So BY COUNTRY = column 1, where SUM RETAIL_COST = column 2. Odd how its laid out, but that is how they do it.

TABLE NAME
SUM COLUMN3
COLUMN4
BY COLUMN1
BY COLUMN2

Columns sometimes are referenced as N as well.. N1, N2, N3, etc..

I had tried to do colors before with no success, so I also learned something.. Always learning in this product.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Gold member
posted Hide Post
Rosie
You can copy it in and change &what_col to the column number the field is in. I have the code in a separate fex and include it. That way I can adjust it to color on what column my sort field is in.


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 74 | Registered: December 23, 2013Report 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     [SOLVED]Chart - Pie Slice Color tied to Series Name

Copyright © 1996-2020 Information Builders