I've searched and not finding my answer. I have a series of about 25 Stacked Bar Graphs graphs...using the same data in different ways. Everything is based on a Reason Code with about 15 differnt values. Some graphs may have only 3 reason codes ploted, some might have all 15. The user would like the Reasons to always be the same color. For instance..Reason 'FELL OFF THE BOAT' should always be Red. Reason "SUNK THE BOAT' Should always be Green and so on. I need to be able to control the setfillcolor based on the value of the Reason, not the Series or Group.This message has been edited. Last edited by: Prarie,
In Focus since 1993. WebFOCUS 7.7.03 Win 2003
April 02, 2009, 01:10 PM
Francis Mariani
Prarie,
It's my guess that there is no way to do that via conventional means, but you could use WebFOCUS to generate the Java colour coding lines. This would unfortunately mean going through the data twice, once to produce the Java colour coding lines and once to produce the graph.
Here's a quick example that seems to work:
-*-- graph_fixed_colour.fex --------------------------------
-SET &ECHO='ALL';
SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA
-RUN
DEFINE FILE CAR
JAVACOLOR1/A23 = 'setFillColor(getSeries(';
JAVACOLOR2/A12 = '),new Color(';
JAVACOLOR3/A03 = '));';
COUNTRY_COLOUR/A11 = DECODE COUNTRY (
'ENGLAND' '255,0,0' ,
'FRANCE' '0,255,0' ,
'ITALY' '0,0,255' ,
'JAPAN' '0,255,255',
'W GERMANY' '255,255,0',
ELSE '255,0,255');
END
-RUN
TABLE FILE CAR
SUM
COMPUTE COUNTRY_COUNTA/D6 = COUNTRY_COUNTA + 1; NOPRINT
COMPUTE COUNTRY_COUNTB/D6 = COUNTRY_COUNTA - 1; NOPRINT
COMPUTE COUNTRY_COUNTC/A6 = STRIP(6, FTOA(COUNTRY_COUNTB, '(D6c)', 'A6'), ' ', 'A6'); NOPRINT
COMPUTE JAVACOLOURA/A200 =
JAVACOLOR1 || COUNTRY_COUNTC || JAVACOLOR2 || COUNTRY_COLOUR || JAVACOLOR3;
BY COUNTRY NOPRINT
WHERE COUNTRY NE 'ENGLAND'
ON TABLE HOLD AS HJAVACOLOUR
END
-RUN
GRAPH FILE CAR
SUM
SALES
BY COUNTRY
WHERE COUNTRY NE 'ENGLAND'
ON GRAPH SET GRAPHSTYLE *
-INCLUDE HJAVACOLOUR
ENDSTYLE
END
As long as the same filters are used in both passes though the data, this should work.
Try excluding a different Country and rerun the graph - England is always red, Germany is always yellow...
I realize this is a very simple graph and you may not be able to do this in a complex one.
The Country colour could be in an INCLUDE to standardize the colours used, so could some of the other code generating the Java colour coding lines.
Hopefully this gives you an idea or three...
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 02, 2009, 01:28 PM
Prarie
Thanks Francis...that is very interesting and brings up a lot of possiblities..but I'm afraid I'm lost on what Country_count computes are for?
April 02, 2009, 01:33 PM
Francis Mariani
I'm sorry I gave no explanations! If you "View Source" you'll see that the Java colour coding lines look like this:
There's one line for every graph object(?), from zero to 99. The computes just create the 0, 1, 2, 3... The first compute creates 1, 2, 3, 4... The second compute subtracts 1 from the value to get 0, 1, 2, 3... The third converts the value to alpha and strips the leading blanks. This is then used in the final compute to generate the Java colour coding line.
Run this code to see what happens:
-SET &ECHO='ALL';
SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA
-RUN
DEFINE FILE CAR
JAVACOLOR1/A23 = 'setFillColor(getSeries(';
JAVACOLOR2/A12 = '),new Color(';
JAVACOLOR3/A03 = '));';
COUNTRY_COLOUR/A11 = DECODE COUNTRY (
'ENGLAND' '255,0,0' ,
'FRANCE' '0,255,0' ,
'ITALY' '0,0,255' ,
'JAPAN' '0,255,255',
'W GERMANY' '255,255,0',
ELSE '255,0,255');
END
-RUN
TABLE FILE CAR
SUM
COMPUTE COUNTRY_COUNTA/D6 = COUNTRY_COUNTA + 1;
COMPUTE COUNTRY_COUNTB/D6 = COUNTRY_COUNTA - 1;
COMPUTE COUNTRY_COUNTC/A6 = STRIP(6, FTOA(COUNTRY_COUNTB, '(D6c)', 'A6'), ' ', 'A6');
COMPUTE JAVACOLOURA/A200 =
JAVACOLOR1 || COUNTRY_COUNTC || JAVACOLOR2 || COUNTRY_COLOUR || JAVACOLOR3;
BY COUNTRY NOPRINT
-*WHERE COUNTRY NE 'W GERMANY'
-*ON TABLE HOLD AS HJAVACOLOUR
END
-RUN
-EXIT
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 02, 2009, 01:43 PM
Prarie
Ok...I get it...let me play and see what I can do. Thanks...I'll report back.
April 02, 2009, 02:03 PM
Laure
I'm doing this with the following code
GRAPH FILE..... SUM FIELD1 CHECKVALUE NOPRINT BY FILED2 ACROSS FIELD3 ..... ENDSTYLE ON GRAPH SET STYLE * DEFMACRO=Condition_1, COLOR=RGB(0 100 0), WHEN=N3 EQ 'Y', $ DEFMACRO=Condition_2, COLOR=RGB(255 215 0), WHEN=N3 EQ 'N', $ TYPE=DATA, ACROSSCOLUMN=N1, MACRO=Condition_1, $ TYPE=DATA, ACROSSCOLUMN=N1, MACRO=Condition_2, $ ENDSTYLE
I'm graphing a 4 series, but only show two colors depending on another field that I don't display.
Check out th Applying Conditional Styling to a graph section of the Creating Reports with WebFOCUS Language....This message has been edited. Last edited by: Laure,
-SET &ECHO='ALL';
GRAPH FILE CAR
SUM
COUNTRY NOPRINT
SALES
ACROSS COUNTRY
-*WHERE COUNTRY NE 'W GERMANY'
ON GRAPH SET STYLE *
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(255 0 255), $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(255 0 255), $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(255 0 0) , WHEN= COUNTRY EQ 'ENGLAND' , $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(0 255 0) , WHEN= COUNTRY EQ 'FRANCE' , $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(0 0 255) , WHEN= COUNTRY EQ 'ITALY' , $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(0 255 255), WHEN= COUNTRY EQ 'JAPAN' , $
TYPE=REPORT, ACROSSCOLUMN=SALES, COLOR=RGB(255 255 0), WHEN= COUNTRY EQ 'W GERMANY', $
ENDSTYLE
END
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 02, 2009, 03:33 PM
Prarie
Well I had already done Fransis method when i saw the other tip..and now I have control of my colors...but I have no legend anymore.
April 02, 2009, 04:39 PM
Laure
The method I posted, while it will display a legend, I haven't been able to control the colors. They default. Maybe someone else has been able to do this?
ON GRAPH SET GRAPHSTYLE * setDepthRadius(0); setSeriesAreRows(false); setLegendDisplay(true); setPlace(true); ENDSTYLE
April 09, 2009, 11:36 AM
Laure
Francis, Your code works great and I'm looking to adapt it to keep static colors for multiple graphs shown on the same BID page and display those same colors in the legend which my . The issue I'm having is that I can not get your code to run under MRE. The -INCLUDE looks for a FEX and gives me an error.
Error occurred. ERROR: ERROR_MR_FEX_NOT_FOUND Can't create item object based on provided item key HJAVACOLOUR.fex.
I've tried setting the APP HOLD to the application folder and then doing -INCLUDE APP/HJAVACOLOUR
but still I get the same error. Do you have a suggestion on how to get around MRE looking for a .FEX on the -INCLUDE?
I have never been able to make this work properly...will keep playing. My Graphs are quite complex...with Loops and stuff.
May 21, 2009, 11:59 AM
Prarie
I'm back.
I have never been able to get this to work. Here is what I have below. Some of the graphs may have only 3 reasons...some may have all of them. So the colors are never consistant. Any other thoughts on this?