Focal Point
[SHARING] How to add $ OR % sign in tooltip

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

March 08, 2019, 11:44 AM
MartinY
[SHARING] How to add $ OR % sign in tooltip
I have found the following regarding tooltip where several people are requesting to add the $ OR % sign.
The problem with that is, as per below sample, all tooltip have the same displayed format.
So if you have multiples columns in different format you are screwed.

For percentage numbers, it is not possible to use a custom format as for currency because IB apply the Custom Numeric Format Stings as defined at:
Custom Numeric Format Strings
and having a % sign added (such as '#.#%') result in having your value multiplied by 100 as stated in above link.

To add the $ sign in tooltip (assuming K $)
*GRAPH_JS
autoNumberFormats:{tooltip: '#,### $'}
*END


To add the % sign in tooltip
*GRAPH_JS
autoNumberFormats:{tooltip: function(n){ return n + ' %';}}
*END


Sample where % sign is displayed to ALL tooltip
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 /P6 = (RETAIL_COST - DEALER_COST) / DEALER_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);
*END

*GRAPH_JS
-*autoNumberFormats:{tooltip: '#,### $'}

autoNumberFormats:{tooltip: function(n){ return n + ' %';}}
*END

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

This message has been edited. Last edited by: MartinY,


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
March 08, 2019, 12:57 PM
FP Mod Chuck
Good One Thanks for sharing!


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats