Focal Point
[SOLVED] Dual Axis Label Formats

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

March 06, 2019, 04:53 PM
JulieA
[SOLVED] Dual Axis Label Formats
I looked at the post [SOLVED] Format labels in dual axis graph in which Doug provided an expert solution to the issue of having two different dual axis label formats in a post dated July 2 around 10:59 a.m.

I integrated parts of it with some code we have here and worked with it quite a bit the past few days.

I had another team member look at it, too, and he tinkered with it a while. I'm having the same problem as outlined in the aforementioned post. I can get one or the other labels, but not both.

Here is the code I currently have:

*GRAPH_SCRIPT
setTextFormatPreset(getDataText(),0);
setDisplay(getY1Title(),false);
setPlaceResize(getY2Title(),0);
setFontStyle(getY2Title(),2);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),9);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeInPoints(getY2Label(),9);
setPlaceResize(getY1Label(),0);
setTextFormatPattern(getY1Label(),"#%");
setTextFormatPreset(getY1Label(),28);
setTextString(getY2Title(),"Dollars");
setDisplay(getY2Title(),false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"$#");
setDataTextDisplay(true);
setSeriesLabel(0,"Percent");
setSeriesLabel(1,"Dollars");
setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);
setDisplay(getO1MajorGrid(),false);
setGridStepAuto(getY2MajorGrid(),false);
setGridStep(getY2MajorGrid(),6)
setAltFmtFrameNumColors(getY2AltFmtFrame(),5);
setScaleMax(getY1Axis(),100.0);
setGridStepAuto(getY1MajorGrid(),false);
setGridStep(getY1MajorGrid(),20.0);
setDisplay(getDataText(0),true);
setDisplay(getDataText(1),true);
setDataTextPosition(1);
setTextFormatPattern(getDataText(0),"#%");
setTextFormatPreset(getDataText(),28);
setDataTextPosition(1);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(),6); 


The code results in data labels (sitting above the bars) of $52 and $25,212.
When you hover over the bars, I get 52% and $25,212 as per desired output.

I understand I need to set the appropriate formats. Just to be certain I understood them as thoroughly as I thought previously, I reviewed this information
 https://webfocusinfocenter.inf...s/source/02_3d31.htm  
.

I am clearly missing something here, and I'd appreciate any assistance.

Thank you.

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


WebFocus 8.2.04
WebFocus 8.2.04

March 07, 2019, 07:57 AM
MartinY
Hi Julie,

Here what, if I understood properly, you should adjust from the below lines
setDataTextPosition(1);
setTextFormatPattern(getDataText(0),"#%");
setTextFormatPreset(getDataText(),28);
setDataTextPosition(1);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(),6);

Should become
setDataTextPosition(1);
setTextFormatPattern(getDataText(0),"#%");
setTextFormatPreset(getDataText(0),28);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(1),6);


Using : setTextFormatPreset(getDataText()..... set the setTextFormatPreset for all DataText.
So if you want to have different one, you should specify to which one as you did for setTextFormatPattern

And pay attention not to have duplicate "set" lines, otherwise only the last one will be in effect (such as setDataTextPosition that was duplicated but in this case with the same option

As a complete sample:
GRAPH FILE CAR
SUM COMPUTE PCT /P6 = (RETAIL_COST - DEALER_COST) / RETAIL_COST * 100;
    DEALER_COST
BY CAR
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 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 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, $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setPieFeelerTextDisplay(1);

setDisplay(getY1Title(),false);
setPlaceResize(getY2Title(),0);
setFontStyle(getY2Title(),2);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),9);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeInPoints(getY2Label(),9);

setPlaceResize(getY1Label(),0);
setTextFormatPattern(getY1Label(),"#%/100");
setTextFormatPreset(getY1Label(),28);
setTextString(getY2Title(),"Dollars");
setDisplay(getY2Title(),false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"$#");

setSeriesLabel(0,"Percent");
setSeriesLabel(1,"Dollars");
setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);

setDisplay(getO1MajorGrid(),false);
setGridStepAuto(getY2MajorGrid(),false);
setGridStep(getY2MajorGrid(),6)
setAltFmtFrameNumColors(getY2AltFmtFrame(),5);
setScaleMax(getY1Axis(),100.0);
setGridStepAuto(getY1MajorGrid(),false);
setGridStep(getY1MajorGrid(),20.0);

setDataTextDisplay(true);
setDisplay(getDataText(0),true);
setDisplay(getDataText(1),true);
setDataTextPosition(1);
setTextFormatPattern(getDataText(0),"#%/100");
setTextFormatPreset(getDataText(0),28);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(1),6);


*GRAPH_JS_FINAL
"pieProperties": {
    "holeSize": "0%"
},
"agnosticSettings": {
    "dual": true,
    "chartTypeFullName": "Bar_Clustered_Dual_Axis"
}
*END
ENDSTYLE
END
-RUN




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
March 07, 2019, 08:58 AM
Doug
This leads me to ask: How can we get the value to be display 'On Hover' to match the value displayed at the top of the bars. In this example The values display On Hover are the same but missing the percent sign / currency symbol.

IMHO: The values displayed should be the same in all cases.

I do appreciate the use of the two 'setSeriesLabel' statements to show 'Dollars' and 'Percent'.

Then, I'll push this a bit and ask if it can be done within InfoAssist.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
March 07, 2019, 09:35 AM
MartinY
quote:
Then, I'll push this a bit and ask if it can be done within InfoAssist.

I think that you're pushing a little too much your luck Big Grin


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
March 07, 2019, 12:59 PM
JulieA
MartinY:

Thank you for the reply. I appreciate it.

Unfortunately, changing the code's few lines makes the situation much worse.

Right now, when I hover over both bars, the hovers perform correctly. I get % and $ signs appropriately.

When I look above the bars, I get labels above each bar, both with the dollar sign.

After I changed those few lines of code, the dollar sign no longer appears above the bar with dollars. The bar with percentages no longer displays no sign either. Additionally, the hover feature over the percentage bar results in 5,278''%.


If I followed the thread after you made your suggestion, I might have to adjust the hovers/tooltips. However, why would the code eliminate the signs in the data labels above the bars?


I've posted code again.


 setUseSeriesShapes(true);
setMarkerSizeDefault(50);
setReportParsingErrors(false);
setSelectionEnableMove(false);
setPieFeelerTextDisplay(1);
setDepthAngle(45);
setPieTilt(10);
setPieDepth(70);
setDepthRadius(0);
setTextFormatPreset(getDataText(),0);
setDisplay(getY1Title(),false);
setFontName(getY1Label(),"Calibri");
setFontName(getY2Title(),"Calibri");
setFontName(getY2Label(),"Calibri");
setFontName(getDataText(),"Calibri");
setFontName(getO1Title(),"Calibri");
setFontName(getX1Title(),"Calibri");
setFontName(getSubtitle(),"Calibri");
setFontName(getAllText(),"Calibri");
setFontSizeAbsolute(getY2Title(),true);
setFontSizeInPoints(getY2Title(),9);
setPlaceResize(getY2Title(),0);
setFontStyle(getY2Title(),2);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),9);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeInPoints(getY2Label(),9);
setPlaceResize(getY1Label(),0);
setTextFormatPattern(getY1Label(),"#%");
setTextFormatPreset(getY1Label(),28);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"$#");
setDisplay(getLegendArea(),false);
setDisplay(getLegendArea(),true);
setFontName(getLegendText(),"Calibri");
setFontSizeAbsolute(getLegendText(),true);
setFontSizeInPoints(getLegendText(),9);
setPlaceResize(getLegendText(),0);
setDataTextDisplay(true);
setSeriesLabel(0,"Percent");
setSeriesLabel(1,"Dollars");
setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);
setDisplay(getO1MajorGrid(),false);
setGridStepAuto(getY2MajorGrid(),false);
setGridStep(getY2MajorGrid(),6)
setAltFmtFrameNumColors(getY2AltFmtFrame(),5);
setDisplay(getY1MajorGrid(),false);
setDisplay(getY2MajorGrid(),false);
setDisplay(getO1MajorGrid(),false);
setScaleMax(getY1Axis(),100.0);
setGridStepAuto(getY1MajorGrid(),false);
setGridStep(getY1MajorGrid(),20.0);
setDisplay(getDataText(0),true);
setDisplay(getDataText(1),true);
setDataTextPosition(1);
-*The code below is what I had that gave me dollar signs only for both data labels above the bars. I did eliminate the duplicate setDataTextPosition(1) line you referenced earlier. 
-*setTextFormatPattern(getDataText(0),"#%");
-*setTextFormatPreset(getDataText(),28);
-*setTextFormatPattern(getDataText(1),"$#");
-*setTextFormatPreset(getDataText(),6);

-*The code you provided.
setTextFormatPattern(getDataText(0),"#%");
setTextFormatPreset(getDataText(0),28);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(1),6); 



WebFocus 8.2.04
WebFocus 8.2.04

March 07, 2019, 01:39 PM
MartinY
Julie,

Below a simplified version (without duplicate setting row and/or opposite setting)
1- where the y-axis labels have the % or K attribute for thousand (which I think it's better since it takes less space to display),
2- where the bar top data text have also the proper % or $ sign,
3- but where the tooltip DOES NOT display % or $ (which seems not possible to have with VBAR2AX) but with the proper value displayed.

ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
SET HTMLENCODE=ON
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
SUM COMPUTE PCT /P6C = (RETAIL_COST - DEALER_COST) / RETAIL_COST * 100;
    DEALER_COST
BY CAR
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 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 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, $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);

setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);

setFontName(getAllText(),"Calibri");
setFontName(getSubtitle(),"Calibri");
setFontName(getDataText(),"Calibri");
setFontName(getO1Title(),"Calibri");
setFontName(getO1Label(),"Calibri");
setFontName(getY1Label(),"Calibri");
setFontName(getY2Label(),"Calibri");
setFontName(getLegendText(),"Calibri");

setDisplay(getLegendArea(),true);
setPlaceResize(getLegendText(),0);
setFontSizeAbsolute(getLegendText(),true);
setFontSizeInPoints(getLegendText(),9);

setSeriesLabel(0,"Percent");
setDisplay(getY1Title(),false);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),9);
setTextFormatPattern(getY1Label(),"#%/100");
setTextFormatPreset(getY1Label(),28);

setSeriesLabel(1,"Dollars");
setDisplay(getY2Title(),false);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeInPoints(getY2Label(),9);
setTextFormatPattern(getY2Label(),"$#");
setTextFormatPreset(getY2Label(),7);

setDataTextPosition(1);
setDisplay(getDataText(0),true);
setTextFormatPattern(getDataText(0),"#%/100");
setTextFormatPreset(getDataText(0),28);
setDisplay(getDataText(1),true);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPreset(getDataText(1),6);

setDisplay(getO1MajorGrid(),false);
setScaleMax(getY1Axis(),100.0);
setGridStepAuto(getY1MajorGrid(),false);
setGridStep(getY1MajorGrid(),20.0);

*GRAPH_JS_FINAL
"agnosticSettings": {
    "dual": true,
    "chartTypeFullName": "Bar_Clustered_Dual_Axis"
}
*END
ENDSTYLE
END
-RUN



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
March 08, 2019, 09:04 AM
JulieA
Martin,

Thank you for that simplified code.
Unfortunately, it did not work for us. It is sleek code though and extremely easy to follow.

As a workaround, we got the code to a point where our hovers work and have the appropriate signs. Additionally, the data labels appear above the bars as per our desired output. The labels just don't have any percentage or dollar signs appearing with them.

  ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET EMBEDHEADING ON
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 1
ON GRAPH SET LOOKGRAPH VBAR2AX
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
*END
INCLUDE=stylesheet here,
TYPE=REPORT, TITLETEXT='WebFOCUS Report', ORIENTATION=LANDSCAPE, $
TYPE=HEADING, JUSTIFY=LEFT, FONT='Calibri', SIZE=10, COLOR=RGB(0 0 0), STYLE=BOLD, $
TYPE=FOOTING, JUSTIFY=RIGHT, FONT='Calibri', SIZE=8, COLOR=RGB(0 0 0), STYLE=NORMAL, $
*GRAPH_SCRIPT
setUseSeriesShapes(true);
setMarkerSizeDefault(50);
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDepthAngle(45);
setPieTilt(10);
setPieDepth(70);
setDepthRadius(0);
setTextFormatPreset(getDataText(),0);
setDisplay(getY1Title(),false);
setFontName(getY1Label(),"Calibri");
setFontName(getY2Title(),"Calibri");
setFontName(getY2Label(),"Calibri");
setFontName(getDataText(),"Calibri");
setFontName(getO1Title(),"Calibri");
setFontName(getX1Title(),"Calibri");
setFontName(getSubtitle(),"Calibri");
setFontName(getAllText(),"Calibri");
setFontSizeAbsolute(getY2Title(),true);
setFontSizeInPoints(getY2Title(),9);
setPlaceResize(getY2Title(),0);
setFontStyle(getY2Title(),2);
setFontSizeAbsolute(getY1Label(),true);
setFontSizeInPoints(getY1Label(),9);
setFontSizeAbsolute(getY2Label(),true);
setFontSizeInPoints(getY2Label(),9);
setPlaceResize(getY1Label(),0);
setTextFormatPreset(getY1Label(),28);
setTextString(getY2Title(),"Dollars");
setDisplay(getY2Title(),false);
setTextFormatPreset(getY2Label(),-1);
setTextFormatPattern(getY2Label(),"$#");
setDisplay(getLegendArea(),false);
setDisplay(getLegendArea(),true);
setFontName(getLegendText(),"Calibri");
setFontSizeAbsolute(getLegendText(),true);
setFontSizeInPoints(getLegendText(),9);
setPlaceResize(getLegendText(),0);
setDataTextDisplay(true);
setDisplay(getDataText(),false);
setTextFormatPattern(getDataText(1),"$#");
setTextFormatPattern(getDataText(0),"#.#%");
setDisplay(getDataText(1), false);
setDisplay(getDataText(0),false);
setTextFormatPreset(getDataText(1),6);
setTextFormatPreset(getDataText(0),3);
setSeriesLabel(0,"Percent");
setSeriesLabel(1,"Dollars");
setAxisAssignment( $0, 0);
setAxisAssignment( $1, 1);
setDisplay(getO1MajorGrid(),false);
setGridStepAuto(getY2MajorGrid(),false);
setGridStep(getY2MajorGrid(),6)
setAltFmtFrameNumColors(getY2AltFmtFrame(),5);
setDisplay(getY1MajorGrid(),false);
setDisplay(getY1MajorGrid(),false);
setDisplay(getY2MajorGrid(),false);
setDisplay(getO1MajorGrid(),false);
setScaleMax(getY1Axis(),100.0);
setGridStepAuto(getY1MajorGrid(),false);
setGridStep(getY1MajorGrid(),20.0);
*END
ENDSTYLE
END
-*IA_GRAPH_FINISH
-RUN


The code you see above is what we used only after we started a blank chart with our data, accessed the text editor and replaced the formatting lines with the simplified code you provided in your most recent post. We also added the top part of your code in the SET GRAPH ENGINGE section.

What kept happening was that we could only get one or the other signs to appear in the data labels, but not both, even when using your simplified code. My teammate and colleague tried using your code, too, and he experienced the same results.

Thank you so much for your efforts to help us.


WebFocus 8.2.04
WebFocus 8.2.04

March 08, 2019, 11:46 AM
MartinY
quote:
Originally posted by Doug:
This leads me to ask: How can we get the value to be display 'On Hover' to match the value displayed at the top of the bars. In this example The values display On Hover are the same but missing the percent sign / currency symbol.

IMHO: The values displayed should be the same in all cases.

I do appreciate the use of the two 'setSeriesLabel' statements to show 'Dollars' and 'Percent'.

Then, I'll push this a bit and ask if it can be done within InfoAssist.


Doug,

Take a look at my post:
[SHARE]How to add a $ OR % sign in tooltip


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