I have bar graph in which the numbers are displayed at the top of each bar i.e in the data labels . Is it possible, if I can get the percentage also beside the numbers eg: 6478 55% 31341 70%?
DEFINE FILE CAR SORT /I1 = DECODE COUNTRY ('JAPAN' 1 'ENGLAND' 2 ELSE 3); MEAS_LAT /P10C = IF BODYTYPE EQ 'SEDAN' THEN RETAIL_COST ELSE 0; MEAS_OUT /P10C = IF BODYTYPE NE 'SEDAN' THEN RETAIL_COST ELSE 0; END
ENGINE INT CACHE SET ON -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 MEAS_LAT AS 'LATEST' MEAS_OUT AS 'OUTDATED' BY SORT NOPRINT BY COUNTRY AS ''
ON GRAPH PCHOLD FORMAT JSCHART 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 2 ON GRAPH SET LOOKGRAPH VBAR 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/javaassist/intl/EN/ENIADefault_combine.sty,$ TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $ *GRAPH_SCRIPT setReportParsingErrors(false); setSelectionEnableMove(false); setDisplay(getDataText(0), true); setDataTextDisplay(true); *END ENDSTYLE END -RUNThis message has been edited. Last edited by: Tamra,
Possibly, Defining Custom Tooltips With a Callback Function Page 124 in the manual
You will need to logon to the IBI Techsupport site to view the link.
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information BuildersThis message has been edited. Last edited by: Tamra,
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
February 01, 2017, 12:52 PM
Tamra
Here is a bit more information:
With a field that already containing the value needed in the data label, it makes things a bit easier. However, GRAPH_JS can’t see NOPRINT fields. What you may want to do is to have the field visible in the chart, then go into the GRAPH_JS section of the code and set its visibility using a series call. That way the code would still treat it as a series for purposes of the callback function.
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information Builders
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
February 01, 2017, 01:13 PM
Tamra
The Charting Product Manager replied with the following example:
DEFINE FILE CAR SORT /I1 = DECODE COUNTRY ('JAPAN' 1 'ENGLAND' 2 ELSE 3); MEAS_LAT /P10C = IF BODYTYPE EQ 'SEDAN' THEN RETAIL_COST ELSE 0; MEAS_OUT /P10C = IF BODYTYPE NE 'SEDAN' THEN RETAIL_COST ELSE 0; END
ENGINE INT CACHE SET ON -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 MEAS_LAT AS 'LATEST' MEAS_OUT AS 'OUTDATED' BY SORT NOPRINT BY COUNTRY AS ''
ON GRAPH PCHOLD FORMAT JSCHART 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 2 ON GRAPH SET LOOKGRAPH VBAR 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/javaassist/intl/EN/ENIADefault_combine.sty,$ TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $ *GRAPH_SCRIPT setReportParsingErrors(false); setSelectionEnableMove(false); setDisplay(getDataText(0), true); setDataTextDisplay(true); *END *GRAPH_JS dataLabels: { formatCallback: function(d, s, g) { var sum = d.value / pv.sum(this.data.map(function(el){return el[g];}), function(el){return el.value;}); return this.formatNumber(d.value, '$#') + ' ' + this.formatNumber(sum, '#%'); } },
*END ENDSTYLE END -RUN
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information Builders
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
February 01, 2017, 01:57 PM
MeM
Thank you so much Tamra. Is it also possible if I can get the total % value for all the bars in the data label E.g. instead of having 100% 0%, I can get 20% 10% 35% 15% 10%...
Thank you, Mehak
WebFOCUS 8.2.02 Windows, All Outputs
February 01, 2017, 01:59 PM
MeM
Also, is it possible if you can explain what all variable mean in the code?
WebFOCUS 8.2.02 Windows, All Outputs
February 01, 2017, 02:29 PM
MeM
Tamra,
Also, is it possible to get the % sum of blue one and % sum of yellow one in data labels?
Thank you so much, MM
WebFOCUS 8.2.02 Windows, All Outputs
February 02, 2017, 01:27 PM
Tamra
The best way to answer to your questions is to try to figure out the calculations and run a report to see your results. You may require a HOLD file to sum and sort the data then use COMPUTE to perform your required calculations. Then run a graph off the HOLD file.
In the previous post there is the link to the Chart manual and the page for the function being used.
Let us know your results.
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information Builders
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
February 02, 2017, 02:45 PM
MeM
Per the example above, the percentage is only looking at the country grouping. We are looking to see the percentage for both the latest and outdated series. ie for japan the latest percentage would be 6,478 / 114,286 (the sum of all the blue bars 6,478 + 31,341 + 5,610 + 5,925 + 64,732) not 6,478 / 6,478
Thanks you Mehak
quote:
Originally posted by Tamra: The Charting Product Manager replied with the following example:
DEFINE FILE CAR SORT /I1 = DECODE COUNTRY ('JAPAN' 1 'ENGLAND' 2 ELSE 3); MEAS_LAT /P10C = IF BODYTYPE EQ 'SEDAN' THEN RETAIL_COST ELSE 0; MEAS_OUT /P10C = IF BODYTYPE NE 'SEDAN' THEN RETAIL_COST ELSE 0; END
ENGINE INT CACHE SET ON -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 MEAS_LAT AS 'LATEST' MEAS_OUT AS 'OUTDATED' BY SORT NOPRINT BY COUNTRY AS ''
ON GRAPH PCHOLD FORMAT JSCHART 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 2 ON GRAPH SET LOOKGRAPH VBAR 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/javaassist/intl/EN/ENIADefault_combine.sty,$ TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $ *GRAPH_SCRIPT setReportParsingErrors(false); setSelectionEnableMove(false); setDisplay(getDataText(0), true); setDataTextDisplay(true); *END *GRAPH_JS dataLabels: { formatCallback: function(d, s, g) { var sum = d.value / pv.sum(this.data.map(function(el){return el[g];}), function(el){return el.value;}); return this.formatNumber(d.value, '$#') + ' ' + this.formatNumber(sum, '#%'); } },
*END ENDSTYLE END -RUN
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information Builders