Focal Point
[CLOSED] Dual Axis Chart - Negative Values on One Side

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

February 27, 2020, 09:41 AM
Brandon Andrathy
[CLOSED] Dual Axis Chart - Negative Values on One Side
Hey all,

I'm trying to figure out how to get the 0 values on a dual axis chart scale to be in unison with one and other. with all positive values, this works fine. Not so much with negative values. Here's the car file I'm playing around with.

Does anyone have ideas? It looks like you can be clever with the way the scales calculate. If there's a simpler solution, I'd love to hear what it is Smiler .

 GRAPH FILE car
SUM 
	COMPUTE cost_new/D12.2=IF COUNTRY EQ 'FRANCE' THEN  -2000 ELSE 7400000;
	CAR.CAR.SEATS
BY CAR.CAR.COUNTRY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET VZERO OFF
ON GRAPH SET GRWIDTH 1
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH VBAR2AX
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
*END
INCLUDE=Warm.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);
*GRAPH_JS_FINAL
"pieProperties": {
    "holeSize": "0%"
},
"agnosticSettings": {
    "dual": true,
    "chartTypeFullName": "Bar_Clustered_Dual_Axis"
}
*END
ENDSTYLE
END
-RUN

-*IA_GRAPH_FINISH
 


Thanks in advance!!

This message has been edited. Last edited by: Brandon Andrathy,


WebFOCUS 8204
February 27, 2020, 07:03 PM
Doug
My initial thought is for DEFINE cost_new instead of using COMPUTE. Then SUM cost_new and use cost_new as you first sort with a NOPRINT. Let me know if that works. Otherwise, please be more specific in your requirement.

Or, do you really want a dual axis chart in the first place. What you provided is just bar chart with the sum of two differ fields.

Also please use 'closer number' such as '-2000 and 4000', instead of "-2000 and 7400000" just for visual clarity. You may also want to use AUTOSIZE.
February 28, 2020, 12:08 PM
dbeagan
I'm thinking that the following post is the issue you are trying to solve:
Align both Axis on Dual Axis Graph
Unfortunately, the conclusion is that they don't think it is possible, but there are some suggestions of alternatives.


WebFOCUS 8.2.06
February 28, 2020, 01:58 PM
Doug
If the Align both Axis on Dual Axis Graph post explains the issue, then I think that this is possible. I think that both axis of the dual axis chart should use the min and max of the combined values. That is to say, take the max used for each half of the dual/two charts and the same for the min. That way both are using the same min and max, thus they should be the same with the zero lined up equally. You'll need to account for the zeros and missing values...

It sounds like an interesting challenge that I don't really have time ti accept without verification of and elaboration on the initial requirements. Perhaps an image of what is desired as the final result would help. I just can't imagine it now...
February 28, 2020, 02:01 PM
BabakNYC
Dual Axis charts in general are hard to read and are often misleading. https://blog.datawrapper.de/dualaxis/

However, one way to make Y1 and Y2 have the same 0 line, is to force them to have the same minimum and maximum. In severe cases, that might cause one side to be comparatively so small that you'll hardly be able to read them. But if that's the spec you've been given here's an example. Find out the top and bottom range of one chart and set it to be the same on the other.

  

ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
-DEFAULTH &WF_HTMLENCODE=OFF;
SET HTMLENCODE=&WF_HTMLENCODE

SET ARGRAPHENGINE=JSCHART
-DEFAULTH &WF_EMPTYREPORT=ON;
SET EMPTYREPORT=&WF_EMPTYREPORT

SET EMBEDHEADING=ON
SET GRAPHDEFAULT=OFF
-DEFAULTH &WF_ARVERSION=2;
SET ARVERSION=&WF_ARVERSION

-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';

-DEFAULTH &WF_TITLE='WebFOCUS Report';
GRAPH FILE ibisamp/car
-* Created by Info Assist for Graph
SUM COMPUTE TESTVAL/D12.2=IF COUNTRY EQ 'FRANCE' THEN -5000 ELSE SALES;
CAR.BODY.RETAIL_COST
BY CAR.ORIGIN.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 BAR
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT

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

*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, ORIENTATION=LANDSCAPE, $
TYPE=DATA, COLUMN=N1, BUCKET=x-axis, $
TYPE=DATA, COLUMN=N2, BUCKET=y-axis(1), $
TYPE=DATA, COLUMN=N3, BUCKET=y-axis(2), $
*GRAPH_SCRIPT

setReportParsingErrors(false);
setSelectionEnableMove(false);
setScaleMinAuto(getY2Axis(),false);
setScaleMin(getY2Axis(),-20000.0);
setScaleMaxAuto(getY2Axis(),false);
setScaleMax(getY2Axis(),100000.0);
*GRAPH_JS_FINAL
"pieProperties": {
"holeSize": "0%"
},
"agnosticSettings": {
"dual": true,
"chartTypeFullName": "Bar_Clustered_Dual_Axis"
}

*END
ENDSTYLE
END

-RUN




WebFOCUS 8206, Unix, Windows
March 02, 2020, 09:08 AM
Brandon Andrathy
Thank you Babak. Yeah I considered the option you proposed. Unfortunately the numbers are very different between the two axes. Agreed they are hard to read.

Figured I'd ask.

Appreciate it! I'll go ahead and close this out


WebFOCUS 8204
March 02, 2020, 11:06 AM
Doug
BabakNYC, Pulls thru again... Smiler
I lkie the dual use of the axis. Still needed, to accomplish this, is the min and max values to get the zero value to line-up as requested.
TYPE=DATA, COLUMN=N2, BUCKET=y-axis(1), $
TYPE=DATA, COLUMN=N3, BUCKET=y-axis(2), $
. . .
setScaleMinAuto(getY2Axis(),false);
setScaleMin(getY2Axis(),-20000.0);
setScaleMaxAuto(getY2Axis(),false);
setScaleMax(getY2Axis(),100000.0);