I have a graph that sums up sales by the 2-character state code, and outputs a US choropleth map. If I don't do anything, the default tooltip when you hover shows the state code and the sales number. I want to alter the value to show as currency, and maybe add a line break. I've seen examples using the function callbacks, and I tried that. It works fine for the sales number, but I cannot get the state code to display. Does anyone know what syntax will display the actual value of your BY field in a tooltip? Group label does not do it. Thanks.
EDIT -> I changed the chart type to a bar chart, and the group label part of the function callback returns the correct value, but when you're using a map, it doesn't!
Time to open (another) case...This message has been edited. Last edited by: Mike in DeLand,
Webfocus 8 Windows, Linux
May 22, 2016, 06:03 PM
David Briars
I'm running the same scenario as you, and seeing the same issue (tooltip function callback arguments do not seem to return 'State').
When I do a view source I see an array of state codes and populations:
...
chart.set({
// The following properties were generated by the Reporting Server:
data: [
['CA', 5555555.00],
['IL', 123456789.00],
['IN', 223333.00],
['MN', 112222.00],
['NE', 40000000.00],
['NY', 222222.00],
['SD', 80000000.00],
['WI', 60000000.00]
],
...
However, I don't see anything returned in the callback function, that would support creating a pointer to the correct value in the array.
Here is an example, 'hard coding' a pointer to 'CA' [state = chart.data[0][0];]:
-* File map01.fex
-*
-* Create State Population test data.
-*
APP FI STATEPOP DISK STATEPOP.MAS (LRECL 80
-RUN
-WRITE STATEPOP
-WRITE STATEPOP FILE=STATEPOP,SUFFIX=FOC
-WRITE STATEPOP SEGNAME=SEG1
-WRITE STATEPOP FIELD=STATE,,A20,A20,$
-WRITE STATEPOP FIELD=POPULATION,,I9,A9,$
-RUN
CREATE FILE STATEPOP
MODIFY FILE STATEPOP
FIXFORM STATE/A20 POPULATION/A9
DATA
IL 123456789
WI 60000000
MN 112222
IN 223333
CA 5555555
NY 222222
NE 40000000
SD 80000000
END
-RUN
-*
-* Create Map of state populations.
-*
GRAPH FILE STATEPOP
SUM POPULATION
BY STATE
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH CHOROPLETH
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
setPlace(true); setToolTipStyle("html5");
*END
INCLUDE=endeflt.sty,$
TYPE=REPORT, TITLETEXT='WebFOCUS Report', $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDisplay(getLegendArea(),true);
*GRAPH_JS
"mapProperties": {
"engine": "leaflet",
"leaflet": {
"overlayLayers": [{
"title": "United States of America",
"dataLookup": "properties.state_abbr",
"layerInfo": {
"maxZoom": "-1",
"minZoom": "-1",
"type": "regions"
},
"type": "tdg",
"url": function(){ return tdgchart.getScriptPath() + 'map/US.json'}
}],
"controls": [
{"control": "L.Control.Layers"},
{
"control": "L.Control.Scale",
"options": {
"imperial": true,
"metric": true
}
}
],
"baselayers": [{
"title": "OpenStreetMap",
"layerInfo": {
"maxZoom": 8,
"minZoom": 0,
"attribution": function(){ return "&|copy; <a target='_blank' href='http://www.InformationBuilders.com'>Information Builders</a> | " +
"&|copy; <a target='_blank' href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors";}
},
"url": function(){ return tdgchart.getScriptPath().replace(/\/tdg\/.*/,'') + '/maptiles/osm/{z}/{x}/{y}.png'}
}]
}
},
"heatmapProperties": {"dataColors": [
"#D7191C",
"#FDAE61",
"#FFFFBF",
"#A6D96A",
"#1A9641"
]},
*END
-*
*GRAPH_JS
htmlToolTip: {enabled: true, snap:true}
*END
-*
*GRAPH_JS
series: [
{series: 'reset', tooltip: function(v, s, g) {
state = chart.data[0][0];
return '[b]State: [/b] ' + state +
'<br>' +
'[b]Population: [/b]' + this.formatNumber(v,'#');}}
]
*END
ENDSTYLE
END
This message has been edited. Last edited by: David Briars,
Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
May 23, 2016, 08:42 AM
Mike in DeLand
Yep - just change the chart type to VBAR and the tooltips will show up properly (without your hardcoding of course). I opened a case and am waiting for IBI's response. I bet it's "fixed in the next release".
Webfocus 8 Windows, Linux
May 23, 2016, 09:20 AM
stur0063
quote:
state = chart.data[0][0];
This line showed [object Object] for me in the tooltip.
I spit out all properties to see what we had in there:
for (var prop in this.data[s][g]){
alert(prop);
}
I did a minor tool tip tweak to show see the 2 character state:
chart.data[s][g].name
webFOCUS 8207.15 WindowsServer 2019
May 23, 2016, 09:40 AM
Mike in DeLand
WORKS!!!
IBI owes you some money.
Thank a million!
Webfocus 8 Windows, Linux
May 23, 2016, 10:00 AM
David Briars
I changed from PCHOLD to HOLD, and open in a -HTMLFORM.
The -HTMLFORM contains a HTML5 doctype and a meta X-UA-Compatible tag.
Now the GROUP ID - g - is populating AOK with the state ids.
-* File map01.fex
-*
-* Create State Population test data.
-*
APP FI STATEPOP DISK STATEPOP.MAS (LRECL 80
-RUN
-WRITE STATEPOP
-WRITE STATEPOP FILE=STATEPOP,SUFFIX=FOC
-WRITE STATEPOP SEGNAME=SEG1
-WRITE STATEPOP FIELD=STATE,,A20,A20,$
-WRITE STATEPOP FIELD=POPULATION,,I9,A9,$
-RUN
CREATE FILE STATEPOP
MODIFY FILE STATEPOP
FIXFORM STATE/A20 POPULATION/A9
DATA
IL 123456789
WI 60000000
MN 112222
IN 223333
CA 5555555
NY 222222
NE 40000000
SD 80000000
END
-RUN
-*
-* Create Map of state populations.
-*
GRAPH FILE STATEPOP
SUM POPULATION
BY STATE
ON GRAPH HOLD AS TEST FORMAT JSCHART
ON GRAPH SET VZERO OFF
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 0
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH CHOROPLETH
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setCurveFitEquationDisplay(false);
setPlace(true);
setPlace(true); setToolTipStyle("html5");
*END
INCLUDE=endeflt.sty,$
TYPE=REPORT, TITLETEXT='WebFOCUS Report', $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDisplay(getLegendArea(),true);
*GRAPH_JS
"mapProperties": {
"engine": "leaflet",
"leaflet": {
"overlayLayers": [{
"title": "United States of America",
"dataLookup": "properties.state_abbr",
"layerInfo": {
"maxZoom": "-1",
"minZoom": "-1",
"type": "regions"
},
"type": "tdg",
"url": function(){ return tdgchart.getScriptPath() + 'map/US.json'}
}],
"controls": [
{"control": "L.Control.Layers"},
{
"control": "L.Control.Scale",
"options": {
"imperial": true,
"metric": true
}
}
],
"baselayers": [{
"title": "OpenStreetMap",
"layerInfo": {
"maxZoom": 8,
"minZoom": 0,
"attribution": function(){ return "&|copy; <a target='_blank' href='http://www.InformationBuilders.com'>Information Builders</a> | " +
"&|copy; <a target='_blank' href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors";}
},
"url": function(){ return tdgchart.getScriptPath().replace(/\/tdg\/.*/,'') + '/maptiles/osm/{z}/{x}/{y}.png'}
}]
}
},
"heatmapProperties": {"dataColors": [
"#D7191C",
"#FDAE61",
"#FFFFBF",
"#A6D96A",
"#1A9641"
]},
*END
-*
*GRAPH_JS
htmlToolTip: {enabled: true, snap:true}
*END
-*
*GRAPH_JS
series: [
{series: 'reset', tooltip: function(v, s, g) {
return '<b>State: </b> ' + g +
'<br>' +
'<b>Population: </b>' + this.formatNumber(v,'#');}}
]
*END
ENDSTYLE
END
-RUN
-HTMLFORM BEGIN
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=11;" />
<title>Population by State</title>
</head>
<body>
!IBI.FIL.TEST;
</body>
</html>
-HTMLFORM END
-EXIT
Hopefully this helps you, Mike.
Thanks stur0063! The .name property might be a 8.1 thing, I am on 8.0, but your post got me thinking... :-)
Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
May 23, 2016, 10:33 AM
Mike in DeLand
I tried your exact thing and mine doesn't display the states - it's doing the same thing it did before. I'll stick with your original solution though! Thanks again.
Webfocus 8 Windows, Linux
May 23, 2016, 02:27 PM
GavinL
Little off subject, but thought you might want to know if you didn't already...
When you mouse over the states/charts you get the bright yellow.. To change that to be less dramatic, open file