As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Took me 3 days to get all this working however, the first day was spent writing it in C# on IIS to make sure I understand how D3 worked. Thought I would post it, just in case someone else decided to use D3 within WebFOCUS and pull its data straight from a Synonym instead of loading it via CSV.
This example shows you how to setup WebFOCUS to use D3 and how to execute against a Hold file without the use of creating CSV's and loading via JS.
Setting up WebFOCUS was pulled from a document I got through the chain of people, which looks as if it derived from Summit 2014 User Conference. There was a PowerPoint and a Word document sent to me, both seem to be the exact same wording.
Snip it from Summit document, but altered a little: Downloading and Installing D3
This step, downloading and installing the D3 JavaScript library. Installing and running D3 from the WebFOCUS Client / Repository will be covered later in this document.
Instructions:
1. In your web browser go to http://www.d3js.org.
2. At bottom of the first browser screen full (you might need to scroll down a little) click the link d3.zip. It will download the zip archive https://github.com/mbostock/d3...wnload/v3.4.8/d3.zip
3. d3.zip contains three files.
a. LICENSE
b. d3.js – Delete
i. This file contains special characters that WebFOCUS cannot process. D3 forums have many people yelling about this as far back as 2012 and it still has special characters.
c. d3.min.js – Keep
i. This is a compact version of d3.js and will do everything the same, but without the special characters.
4. Create a folder on your PC, say, d3_zipped, and unzip d3.zip to it.
5. Using your computer’s operating system utilities, say, Microsoft Windows’ File Explorer or the Unix/Linux shell, create a WebFOCUS application folder for d3, e.g.., [b]<WebFOCUS Server>\<drive>$\ibi\apps\d3[/b]
6. Take the files unzipped in step 4 above and copy them to the d3 app folder created in step 5 above.
7. Then, using the WebFOCUS Reporting Server console, add the d3 app folder to the Application Path.
I’m setup now, now what? Now you need to figure out what D3 report you’re going to use.
1. You can go to this URL to find different styles:
a. https://github.com/mbostock/d3/wiki/Gallery
2. For this demo we are going to use:
a. http://bl.ocks.org/NPashaP/9796212
3. Right click on page and view source.
4. Click on the link that looks like this:
a. [b]/NPashaP/raw/9796212/8ed537693ddcb720b79cae93d979385c3c3b08c3/[/b]
5. This will take you to that report only page.
6. Right click on this report and view source.
a. You can click and download the d3.v3.min.js file if you like, but it’s the same as the d3.min.js you have already downloaded earlier. Just make sure you are using the same name as the one you have in the ibi\apps\d3 folder.
7. Download the bipartite.js file and place it in the same folder as the D3.min.js under the ibi\apps\d3 folder on the WebFOCUS server.
I have the report, how do I use it.
1. Go into WebFOCUS or DevStudio and create a folder under content called D3 for this demo. You can call it anything, but to be consistent, we will call it D3.
2. Make sure the user you’re using has access to the CAR Synonym.
3. Right click and create a new FEX, however you would like to do it then save it and name it anything you like.
4. Copy and Paste this code into your FEX.
ENGINE INT CACHE SET ON
*-HOLD_SOURCE
-DEFAULTH &WF_SUMMARY='Summary';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
TABLE FILE CAR
SUM CAR.SPECS.MPG
CNT.CAR.COMP.CAR AS 'CARCT'
PCT.CNT.CAR.COMP.CAR/F7 AS 'CARPCT'
BY CAR.ORIGIN.COUNTRY
ON TABLE HOLD AS File1 FORMAT BINARY
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET ASNAMES MIXED
ON TABLE SET HOLDATTRS ON
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SET STYLE *
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
ENDSTYLE
END
-RUN
-*COMPONENT=Define_FILE1
DEFINE FILE File1
Grouping/A50V='["' || FILE1.FILE1.COUNTRY || '", "' || EDIT ( FILE1.FILE1.MPG ) || '",' || EDIT ( FILE1.FILE1.CARCT ) || ', ' || EDIT ( FILE1.FILE1.CARPCT ) || '],' ;
END
-DEFAULTH &WF_SUMMARY='Summary';
-DEFAULTH &WF_TITLE='WebFOCUS Report';
TABLE FILE File1
BY Grouping AS ''
-*ON TABLE PCHOLD FORMAT ALPHA
ON TABLE HOLD AS MYFILE FORMAT DOC
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
ENDSTYLE
END
-RUN
-HTMLFORM BEGIN
<!DOCTYPE html>
<meta charset="UTF8">
<html lang="en">
<head>
<style>
svg text{
font-size:12px;
}
rect{
shape-rendering:crispEdges;
}
</style>
<script charset="utf-8" type="text/javascript" src="/approot/d3/d3.min.js"></script>
<script charset="utf-8" type="text/javascript" src="/approot/d3/biPartite.js"></script>
</head>
<body>
<script>
var sales_data=[
!IBI.FIL.MYFILE;
];
var width = 900, height = 900, margin ={b:0, t:40, l:170, r:50};
var svg = d3.select("body")
.append("svg").attr('width',width).attr('height',(height+margin.b+margin.t))
.append("g").attr("transform","translate("+ margin.l+","+margin.t+")");
var data = [
{data:bP.partData(sales_data,2), id:'Sales', header:["Car","MPG", "Car MPG Mapping"]}
];
bP.draw(data, svg);
</script>
</body>
</html>
-HTMLFORM END
At the Finish Line Run it and you should get a pretty graph using the CAR Synonym.
Keep in mind, this is a very simple version of using D3, but it shows how you can load this from a hold file instead of creating CSVs, then loading the CSV via Javascript.
Have a happy FOCUS day and let me know if you like of see something I should change to make this demo better.This message has been edited. Last edited by: FP Mod Chuck,
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
I followed your directions here and the fex is in fact running but nothing is rendering on the report. I am running 8.1.05. Are there any additional settings that have to be in/off to recognize js content?
I was able to download the files and build this chart successfully, however theres a chart that my customer wants (sunburst with labels) has JSON formatted data in it as shown below. I'm hoping we can use FORMAT JSON but any thoughts on formatting in such a way? https://embed.plnkr.co/4JMq4o/
Thanks so much -PThis message has been edited. Last edited by: vaayu,
I am not a D3 expert but I googled d3 suburst with labels and found many examples. I think as long as you register them to WebFOCUS the same way you have done with others it should just work.
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005
Note that IBI states they work with D3 charts, but the reality is the D3 charts they are talking about were modified specifically for WebFOCUS by IBI. They have a page, somewhere of a list of D3 charts they can use right out the gate. Now, this doesn't mean your every day D3 chart can't be used. What you can do, is gather your own data, generating the format the D3 charts wants, like I did in the above example, then feed it into the chart. You could also create a separate fex, that generates the required data as some D3 charts want external sources.
It just takes a little bit of an imagination and you can make anything in WebFOCUS work. We wrote a full application using WebFOCUS, not a chart on the site at all. We started using charts, but then as the business changed requirements, we didn't want to have to rewrite what we already did. I didn't use their HTML Builder. Every HTML page is an actual FEX, than I push HTML out and have an external FEX pull the data required for the page. Just think of how it can be architected in your favorite language and do somewhat the same thing in WebFOCUS, while using Portal as the entrance and Magnify as the search engine to find what the customer is looking for.
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
Thank you Chuck/Gavin This may be too much to ask but, would you have few minutes to look at it on webex with me. I feel like I'm close to putting labels but, not quite there yet.
ENGINE INT CACHE SET ON
SET PAGE-NUM=NOLEAD
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
-* Created by Info Assist for Graph
SUM CAR.BODY.SALES
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
BY CAR.CARREC.MODEL
BY CAR.BODY.BODYTYPE
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET VZERO 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 LOOKGRAPH EXTENSION
ON GRAPH SET AUTOFIT ON
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setPieDepth(0);
setPieTilt(0);
setDepthRadius(0);
setPlace(true);
setCurveFitEquationDisplay(false);
*END
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, $
TYPE=DATA, COLUMN=N1, BUCKET= >levels, $
TYPE=DATA, COLUMN=N2, BUCKET= >levels, $
TYPE=DATA, COLUMN=N3, BUCKET= >levels, $
TYPE=DATA, COLUMN=N4, BUCKET= >levels, $
TYPE=DATA, COLUMN=N5, BUCKET= >value, $
*GRAPH_SCRIPT
setReportParsingErrors(false);
setSelectionEnableMove(false);
setDataTextPosition(3);
setDisplay(getDataText(*),true);
setPieFeelerTextDisplay(1);
*GRAPH_JS_FINAL
"pieProperties": {
"holeSize": "0%"
},
"chartType": "com.ibi.sunburst",
"agnosticSettings": {
"chartTypeFullName": "com.ibi.sunburst"
}
*END
ENDSTYLE
END
-RUN
-*IA_GRAPH_FINISH
I modified sunburst.js to add this section and other couple of places hoping to see the labels but no luck yet.
Thank you Chuck, Gavin, please send me an example for sunburst chart with labels. I really like these examples and lot of the charts are similar but our WF HTML Extensions seem a little different, I tried editing sunburst.js but gave up at some point. https://embed.plnkr.co/4JMq4o/ http://bl.ocks.org/metmajer/5480307 Appreciate any thoughts or ideas using this type of chart with WF Thanks in advance!!
Without spending too much time on this (from my part), I have looked through the sunburst.js and I would concentrate your efforts in the area where the segments are built (about line 455) and use what you learn from that section to build your text elements.
However, rather than just modifying the original com.ibi.sunburst at your installation, why not create it as a new HTML extension?
You could use the original as a template.
If you are planning on attending Summit this year then check out the sessions by Dan Weingart - Summit Agenda Link
I've written 4 to date - only one published on GitHub as two were customer specific requirements.
If you have a good understanding of JavaScript and an interest in charting then I commend learning D3. I would also suggest gaining an understanding of SVG graphics and, if you can, HTML canvas.
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004
Here is a rendering of the D3 Sunburst Code from 'Zoomable Sunburst with Labels - Code from Plunker' with data from the GGSALES sample database:
Here is the code, used to create the viz:
-* File SunburstD3Demo.fex
-* Author: D. Briars
-*
-* Extract and summarize data to be visualized.
-*
TABLE FILE GGSALES
SUM DOLLARS
BY REGION
BY ST
ON TABLE HOLD AS HLDSUM FORMAT FOCUS
END
-RUN
-*
-* Create the temporary MacGuyver Master and data file.
-* Code from Focal Point: http://forums.informationbuild...027040786#1027040786
-*
EX -LINES 7 EDAPUT MASTER,FSEQ,C,MEM
FILENAME=FSEQ,SUFFIX=FIX
SEGNAME=CHAR1,SEGTYPE=S0
FIELDNAME=BLANK,BLANK,A1,A1,$
SEGNAME=CHARS,SEGTYPE=S0,PARENT=CHAR1,OCCURS=VARIABLE
FIELDNAME=CHAR,CHARS,A1,A1,$
FIELDNAME=COUNTER,ORDER,I2,I4,$
-RUN
FILEDEF FSEQ DISK FSEQ.FTM
-RUN
-WRITE FSEQ FILEFORMACGUYVERFILEFORMACGUYVERFILEFORMACGUYVER
-RUN
-*
-* Reformat extracted data to JSON
-*
JOIN BLANK WITH REGION IN HLDSUM TO BLANK IN FSEQ AS J1
-*
DEFINE FILE HLDSUM
BLANK/A1 WITH REGION = ' ';
END
-*
TABLE FILE HLDSUM
PRINT REGION NOPRINT
ST NOPRINT
DOLLARS NOPRINT
COUNTER NOPRINT
COMPUTE REGIONRECORD_YN/A1 = IF REGION EQ LAST REGION THEN 'N' ELSE 'Y'; NOPRINT
COMPUTE ENDOFREGION_CODE/A24 = IF LAST REGION EQ ' ' THEN ' ' ELSE IF REGIONRECORD_YN EQ 'Y' THEN ']},' ELSE ' ';
COMPUTE OUTREC/A1024 = IF COUNTER EQ 1 THEN
'{"name": "' | REGION | '", "children": [ '
ELSE
'{"name": "' | ST | '", "size": ' | FPRINT(DOLLARS, 'I9', 'A9') | '},';
BY REGION NOPRINT
BY ST NOPRINT
BY COUNTER NOPRINT
-*
WHERE TOTAL ((COUNTER EQ 1) AND (REGIONRECORD_YN EQ 'Y')) OR
COUNTER EQ 2;
-*
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS SUNJSON FORMAT ALPHA
END
-RUN
-*
-* Visualization Presentation to User.
-* D3 Sunburst Code from: Zoomable Sunburst with Labels - Code from Plunker: https://embed.plnkr.co/4JMq4o/
-*
-HTMLFORM BEGIN
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
path {
stroke: #fff;
fill-rule: evenodd;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>
var width = 760,
height = 520,
radius = Math.min(width, height) / 2;
var x = d3.scale.linear()
.range([0, 2 * Math.PI]);
var y = d3.scale.linear()
.range([0, radius]);
var color = d3.scale.category20();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + (height / 2 + 10) + ")");
var partition = d3.layout.partition()
.value(function (d) {
return d.size;
});
var arc = d3.svg.arc()
.startAngle(function (d) {
return Math.max(0, Math.min(2 * Math.PI, x(d.x)));
})
.endAngle(function (d) {
return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx)));
})
.innerRadius(function (d) {
return Math.max(0, y(d.y));
})
.outerRadius(function (d) {
return Math.max(0, y(d.y + d.dy));
});
var g = svg.selectAll("g")
.data(partition.nodes(getData()))
.enter().append("g");
var path = g.append("path")
.attr("d", arc)
.style("fill", function (d) {
return color((d.children ? d : d.parent).name);
})
.on("click", click);
var text = g.append("text")
.attr("transform", function (d) {
return "rotate(" + computeTextRotation(d) + ")";
})
.attr("x", function (d) {
return y(d.y);
})
.attr("dx", "6") // margin
.attr("dy", ".35em") // vertical-align
.attr("font-family", "sans-serif")
.attr("fill","black")
.text(function (d) {
return d.name;
});
function click(d) {
// fade out all text elements
text.transition().attr("opacity", 0);
path.transition()
.duration(750)
.attrTween("d", arcTween(d))
.each("end", function (e, i) {
// check if the animated element's data e lies within the visible angle span given in d
if (e.x >= d.x && e.x < (d.x + d.dx)) {
// get a selection of the associated text element
var arcText = d3.select(this.parentNode).select("text");
// fade in the text element and recalculate positions
arcText.transition().duration(750)
.attr("opacity", 1)
.attr("transform", function () {
return "rotate(" + computeTextRotation(e) + ")"
})
.attr("x", function (d) {
return y(d.y);
});
}
});
}
d3.select(self.frameElement).style("height", height + "px");
// Interpolate the scales!
function arcTween(d) {
var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),
yd = d3.interpolate(y.domain(), [d.y, 1]),
yr = d3.interpolate(y.range(), [d.y ? 20 : 0, radius]);
return function (d, i) {
return i ? function (t) {
return arc(d);
} : function (t) {
x.domain(xd(t));
y.domain(yd(t)).range(yr(t));
return arc(d);
};
};
}
function computeTextRotation(d) {
return (x(d.x + d.dx / 2) - Math.PI / 2) / Math.PI * 180;
}
function getData() {
return {
"name": "Sales",
"children": [
!IBI.FIL.SUNJSON;
]}
]}
}
</script>
</body>
</html>
-HTMLFORM END
I've been meaning to try a 'WebFOCUS - D3 Mashup' for a while now. Glad to have the encouragement.
Notes:
The code is currently calling D3 via a Content Delivery Network. I would probably download D3.js and host it from an application folder, as Gavin suggests, before thinking about actually using D3.
WebFOCUS has always integrated well with other technologies. WF <-> D3 is yet another example.
I would probably recheck to make sure one of the WF JSCHARTs didn't meet user needs, before implementing a D3 chart.
I know HOLD FORMAT JSON is a new 81 feature, but I haven't yet had a chance to experiment with it. If anyone else has, I'd love to hear of your experience with it.
I believe with 82, WF more fully supports D3, but being on 81, I haven't had a chance to review.
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
Gavin/David anyone have an example of this? I have currently implemented a Google chart (https://developers.google.com/chart/interactive/docs/gallery/timeline#configuration-options) but have found it contains a bug with the tooltip which has not been fixed in the 4 years it has been known. I am doubtful it will be fixed anytime soon and it is causing the chart to be useless since tooltips are a must. I would much prefer to use the D3 charts anyway since they are easier to customize once you learn them.
thanks,
Marita Locklear
WebFOCUS 8.2.02M Windows Server/8.2.02M All Outputs