Focal Point
[SOLVED] Waterfall Chart Style Question

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

February 13, 2015, 04:45 PM
Enigma006
[SOLVED] Waterfall Chart Style Question
Hello

I am working on waterfall chart and having couple of issues. I mimicked with CAR file.
1. I am trying to remove black line that is connecting the bars
2. I am trying to get positive bars with 1 color and -ve bars with another color

DEFINE FILE CAR
LOSS/I8 = -4500;
END

GRAPH FILE CAR
SUM
	DEALER_COST
	RETAIL_COST
	LOSS
	SALES
ON GRAPH SET LOOKGRAPH VWATERFL
ON GRAPH SET BARNUMB ON
ON GRAPH SET VAXIS 500
ON GRAPH SET HAXIS 600
ON GRAPH SET VZERO ON
ON GRAPH SET GRAPHSTYLE *
setStackedDataValueSum(false);
setPlace(true);
setDepthRadius(0);
setDepthAngle(0);
setTransparentBorderColor(getChartBackground(),true);
setTransparentFillColor(getFrame(),true);
setWaterfallGroupMode(8,3);
setDisplay(getY1MajorGrid(),false);
setDisplay(getO1MajorGrid(),false);
setPlaceRotate(getO1Title(),0);
setTextRotation(getO1Label(),0);
setFontSizeAbsolute(getO1Label(), true);
setFontSizeInPoints(getO1Label(), 11);
setPlaceResize(getO1Label(), 0);
setFontSizeAbsolute(getY1Label(), true);
setFontSizeInPoints(getY1Label(), 12);
setPlaceResize(getY1Label(), 0);
setFontStyle(getDataText(),0);
setFontStyle(getY1Label(),0);
setFontStyle(getO1Label(),0);
setBorderColor(getO1AxisLine(),new Color(255,255,255));
setBorderColor(getY1ZeroLine(),new Color(255,255,255));
setFillColor(getY1ZeroLine(),new Color(255,255,255));
setBorderColor(getY1AxisLine(),new Color(255,255,255));
setDisplay(getLegendArea(),false);
setFontSizeAbsolute(getDataText(), true);
setFontSizeInPoints(getDataText(), 12);
setPlaceResize(getDataText(), 0);
setPlaceRotate(getO1Label(),0);
setPlaceAlign(getO1Label(),0);
setTextRotation(getO1Label(),1);
ENDSTYLE
END



Please suggest.

Thank you

This message has been edited. Last edited by: <Kathryn Henning>,


8.1.05
HTML,PDF,EXL2K, Active, All
February 14, 2015, 12:14 AM
Ram Prasad E
To remove connecting lines, add below set command.

setDisplay(getWaterfallLine(), false);

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 15, 2015, 01:20 AM
Ram Prasad E
Try below code. I am able to highlight loss column, but without datatext display.
[CODE]

APP PATH IBISAMP
-RUN

DEFINE FILE CAR
LOSS/I8 = -1500;
DUMMY_A/I1= IF COUNTR EQ 'ENGLAND' THEN 1 ELSE IF COUNTRY EQ 'FRANCE' THEN 2 ELSE IF COUNTRY EQ 'ITALY' THEN 3 ELSE 4;
XAXIS_LABEL/A20= IF COUNTR EQ 'ENGLAND' THEN 'DEALER_COST' ELSE IF COUNTRY EQ 'FRANCE' THEN 'RETAIL_COST' ELSE IF COUNTRY EQ 'ITALY' THEN 'LOSS' ELSE 'SALES';
MEASURE_A/D20.2 MISSING ON=IF COUNTR EQ 'ENGLAND' THEN DEALER_COST ELSE IF COUNTRY EQ 'FRANCE' THEN RETAIL_COST ELSE IF COUNTRY EQ 'ITALY' THEN MISSING ELSE RETAIL_COST;
MEASURE_B/D20.2 MISSING ON=IF COUNTRY EQ 'ITALY' THEN LOSS ELSE MISSING;
END

GRAPH FILE CAR
SUM
MEASURE_A AS ''
MEASURE_B AS ''
BY DUMMY_A NOPRINT
BY XAXIS_LABEL AS ''
WHERE COUNTRY EQ 'ENGLAND' OR 'FRANCE' OR 'ITALY' OR 'JAPAN';
ON GRAPH SET LOOKGRAPH VWATERFL
ON GRAPH SET BARNUMB ON
ON GRAPH SET VAXIS 500
ON GRAPH SET HAXIS 600
ON GRAPH SET VZERO ON
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 2
ON GRAPH SET GRAPHSTYLE *
setStackedDataValueSum(false);
setPlace(true);
setDepthRadius(0);
setDepthAngle(0);
setTransparentBorderColor(getChartBackground(),true);
setTransparentFillColor(getFrame(),true);
setWaterfallGroupMode(8,3);
setDisplay(getY1MajorGrid(),false);
setDisplay(getO1MajorGrid(),false);
setPlaceRotate(getO1Title(),0);
setTextRotation(getO1Label(),0);
setFontSizeAbsolute(getO1Label(), true);
setFontSizeInPoints(getO1Label(), 11);
setPlaceResize(getO1Label(), 0);
setFontSizeAbsolute(getY1Label(), true);
setFontSizeInPoints(getY1Label(), 12);
setPlaceResize(getY1Label(), 0);
setFontStyle(getDataText(),0);
setFontStyle(getY1Label(),0);
setFontStyle(getO1Label(),0);
setBorderColor(getO1AxisLine(),new Color(255,255,255));
setBorderColor(getY1ZeroLine(),new Color(255,255,255));
setFillColor(getY1ZeroLine(),new Color(255,255,255));
setBorderColor(getY1AxisLine(),new Color(255,255,255));
setDisplay(getLegendArea(),false);
setFontSizeAbsolute(getDataText(), true);
setFontSizeInPoints(getDataText(), 12);
setPlaceResize(getDataText(), 0);
setPlaceRotate(getO1Label(),0);
setPlaceAlign(getO1Label(),0);
setTextRotation(getO1Label(),1);
setDisplay(getWaterfallLine(), false);
setDisplay(getDataText(), false);
setFillColor(getSeries(0),new Color(0,128,0));
setFillColor(getSeries(1),new Color(255,0,0));
TYPE=DATA, COLUMN=MEASURE_A, COLOR=RED, WHEN = MEASURE_A LE 10000, $
ENDSTYLE
END


[CODE]

Looks like enabling conditional color for bars in waterfall chart is a challenge.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 15, 2015, 05:48 PM
<nick z>
Hi Enigma006,
If you want to display positive numbers green and -ve numbers red, add
setWaterfallStackColorMode(true);
to your procedure.

And as Ram already pointed out add
setDisplay(getWaterfallLine(), false);
if you want to remove the connecting waterfall lines.

Thank you.
Nick.
February 17, 2015, 09:21 AM
Enigma006
Thanks Ram. This worked
quote:
Originally posted by Ram Prasad E:
To remove connecting lines, add below set command.

setDisplay(getWaterfallLine(), false);

Thanks,
Ram



8.1.05
HTML,PDF,EXL2K, Active, All
February 17, 2015, 09:22 AM
Enigma006
quote:
Originally posted by nick z:
Hi Enigma006,
If you want to display positive numbers green and -ve numbers red, add
setWaterfallStackColorMode(true);
to your procedure.

And as Ram already pointed out add
setDisplay(getWaterfallLine(), false);
if you want to remove the connecting waterfall lines.

Thank you.
Nick.


Thanks Nick, I am getting green and red colors.
But can I customize to provide my own color for both positive and negative value?


8.1.05
HTML,PDF,EXL2K, Active, All
February 17, 2015, 09:58 AM
<nick z>
You can't do it in the old Graph engine.
And no New Features are being accepted.

But if you move to WF8.x you will be able to use JSCHART Graph engine.

Here is a sample code that would work in JSCHART output format:


DEFINE FILE CAR
LOSS/I8 = -4500;
END

GRAPH FILE CAR
SUM
	DEALER_COST
	RETAIL_COST
	LOSS
	SALES
ON GRAPH SET LOOKGRAPH VWATERFL
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET BARNUMB ON
ON GRAPH SET VAXIS 500
ON GRAPH SET HAXIS 600
ON GRAPH SET VZERO ON
ON GRAPH SET STYLE *

*GRAPH_JS
legend: {visible:false},
waterfallProperties: {
appendTotalRiser: true,
positiveRiserColor: 'blue',
negativeRiserColor: 'yellow',
connectorLine: {
width: 0,
}

}
*END
ENDSTYLE
END


February 18, 2015, 02:48 AM
Ram Prasad E
Thanks Nick for sharing.

I tried conditional coloring for bars using Java methods. But unable to make it.

As Nick suggested, you can only control bar colors(positive, negative) using javascript styling.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 18, 2015, 10:07 AM
<nick z>
Hi Ram,
I looked at your code and it was a very nice try. However, your LOSS column is not actually a "Loss". If you look closely at your output, the LOSS column is going up. It should have been going down since it's a loss.
And that is because in your stack, you have a mix of Positive(actually missing, but waterfall turns missing into 0) and negative. And Waterfall always turns the sign into whatever the first value is. So it turned your sum into positive. To fix it, just switch the order of your measures:

SUM
MEASURE_B AS ''
MEASURE_A AS ''

And change the colors of course, or your positive values would be in red and negative in green:

setFillColor(getSeries(1),new Color(0,128,0));
setFillColor(getSeries(0),new Color(255,0,0));

Hope this helps.

As for conditional styling, you actually can do it, but you will need a SORT field.

So here is the code that would work in the old graph engine with conditional styling:

GRAPH FILE CAR
SUM COMPUTE NewSALES/D12.2=IF COUNTRY EQ 'ITALY' THEN SALES*-1 ELSE SALES;
BY CAR.ORIGIN.COUNTRY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO 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 VWATERFL
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0); 
*GRAPH_SCRIPT
setFillColor(getSeries(0),new Color(0,128,0));
setDisplay(getWaterfallLine(), false);
setColorMode(1);
*END
DEFMACRO=Condition_1, MACTYPE=RULE, WHEN=N2 LT 0, $
TYPE=DATA, COLUMN=N2, MACRO=Condition_1, COLOR=RGB(255 0 0), $
ENDSTYLE
END



Thanks.
Nick.