Focal Point
[CLOSED] Charting - controling the labels and Legends

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

October 23, 2015, 12:07 PM
Dgraff
[CLOSED] Charting - controling the labels and Legends
My requirement is simple. so I simplified it as much as I could for everyone. Using CAR count model by country and create a pie chart. easy now short of creating another request is there anyway to display. the legend as with the appropriate markers:
ENGLAND 4 22.22%
FRANCE 1 5.56%
ITALY 4 22.22%
JAPAN 2 11.11%
W GERMANY 7 38.89%

Failing that how do I create a maker to display on a report.

Thank you
Duane

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


Duane

WebFOCUS 8.0.7
DS 8.0.7 AS 8.0.7
Windows
Output: Excel, HTML, PDF, AHTML,Mobile
In Focus 1982
October 26, 2015, 03:12 PM
GavinL
I've attempted this many times.. There doesn't seem to be a way to change the text within the legend, unless you create your own off to the side somewhere. OR, you can create a second report and place it beside it, looking like a legend.

As you can see below, you can change colors, fonts, etc, but there isn't a property for changing the actual text. I'd suggest putting it in the tooltip.



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';

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
-* Created by Info Assist for Graph
SUM CNT.CAR.CARREC.MODEL AS 'MODEL'
BY CAR.ORIGIN.COUNTRY
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT 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 PIEMULTI
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
setPieFeelerTextDisplay(1);
*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);
setLegendPosition(2);
setDisplay(getLegendArea(),true);
setPieFeelerTextDisplay(3);
*END
*GRAPH_JS
legend: {
	visible:true,
	backgroundcolor: '#FFFFCC',
    shadow: true,
	markerSize: 10,
-*top, bottom, left, right, free
-*	position: 'free',
-*	xy: {x:200, y:200},
	lineStyle: {
		width: 1,
		color: '#000000'
	},
	labels: {
		color: function(d)
		{
			if(d=='FRANCE')
				return 'red';
			else
				return 'blue';
		},
		font: function(d)
		{
			if(d=='FRANCE')
				return '16pt Verdana';
			else
				return '8pt Verdana';
		},
	},
	title: {
		visible: true,
		text: 'Legend Title',
		font: '10pt Sans-Serif',
		color: 'red',
	},
},
series: [
		{
		 	series: 'reset',
			pattern: 6,
			tooltip: function(d, s, g)
			{
				var allTitles = 'Country,Car,Model';
				var totalColor = '';
				var totalColorClose = '';

				//get raw series label
				var str = this.getSeries(s).label;
				//create an array from the series label.
				var res = str.split(": ");
				var titles = allTitles.split(",");
				var total=0;

				//NOTE: == 8.0.xx code =============
				//get the total of all groups.
				//pv.sum works only for 8.0.xx and prior..
				//==================================
				//total = pv.sum(this.data[g], function(el){return el;});
				//========= EO 8.0.xx code =========

				//NOTE: == 8.1.xx code =============
				//get the total of all groups.
				//This below only works for 8.1.xx and up..
				//==================================
				var valueArr = this.data[0];
				for (var i=0 ;i<valueArr.length;i++) {
					total+=valueArr[i].value;
				}
				//========= EO 8.1.xx code =========

				//validate object and get the value in return.
				if (typeof d === 'object' && d.hasOwnProperty('value'))
					d = d.value;

				var sum = d / total * 100 ;

				//this was done for some charts, show NaN because of no groups.. This forces them to be 100%
				if(!sum)
					sum = d;

				//if data value is under 10000, then turn red.
				if(d<4)
				{
					totalColor = '<font color=\'red\'>[b]';
					totalColorClose = '[/b]</font>';
				}
				//if data value is above 30000, then turn blue.
				else if(d>6)
				{
					totalColor = '<font color=\'blue\'>[b]';
					totalColorClose = '[/b]</font>';
				}

				//build the look of the ToolTip
				var tabData = '<table style=\'border: 1px dotted blue\'>';

				for(var i = 0; i < res.length; i++)
					tabData += '<tr><td style=\'\'>[b]' + titles[i] + ':[/b]</td><td style=\'\'>' + res[i] + '</td></tr>';

				tabData += '<tr><td style=\'\'>[b]Total:[/b]</td><td style=\'\'>' + totalColor + this.formatNumber(d, '#,#') + ' in ' + this.groupLabels[g] + totalColorClose + '</td></tr>';
				tabData += '<tr><td style=\'\'>[b]Percentage:[/b]</td><td style=\'\'>' + sum.toFixed(2) + '% in ' + this.groupLabels[g] + '</td></tr>';
				tabData += '</table>';
				return tabData;
			}
		},
]
*END
ENDSTYLE
END
-RUN




- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server