[Solved]webfocus 8 stacked bar graph legend display issue
plotting stacked bar graph in webFOCUS 8 using car file.I defined a sort field - if bodytype is sedan then 1 else everything is 2.Graphs legend text shows 1 and 2 as description instead of bodytype like sedan,coupe. .etc.Can anyone help me out with this issue.
DEFINE FILE CAR SORTA/I2 = IF BODYTYPE EQ 'SEDAN' THEN 1 ELSE 2;
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 CAR.BODY.SALES BY CAR.BODY.SORTA ACROSS 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 1 ON GRAPH SET GRXAXIS 1 ON GRAPH SET LOOKGRAPH VBRSTK1 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); *END ENDSTYLE END -RUNThis message has been edited. Last edited by: CuriousDev,
WebFOCUS 8 Windows, All Outputs
April 20, 2015, 12:12 PM
MartinY
Try this:
DEFINE FILE CAR
SORTA/I2 = IF BODYTYPE EQ 'SEDAN' THEN 1 ELSE 2;
SORTX/A10 = IF BODYTYPE EQ 'SEDAN' THEN 'SEDAN' ELSE 'OTHER';
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 CAR.BODY.SALES
BY SORTA NOPRINT
BY SORTX
ACROSS 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 2
ON GRAPH SET GRXAXIS 1
ON GRAPH SET LOOKGRAPH VBRSTK1
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);
*END
ENDSTYLE
END
-RUN
[code]
Pay attention to :
[code]
DEFINE FILE CAR
SORTA/I2 = IF BODYTYPE EQ 'SEDAN' THEN 1 ELSE 2;
SORTX/A10 = IF BODYTYPE EQ 'SEDAN' THEN 'SEDAN' ELSE 'OTHER';
END
BY SORTA NOPRINT
BY SORTX
And
ON GRAPH SET GRLEGEND 2
ON GRAPH SET GRXAXIS 1
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
April 20, 2015, 12:15 PM
eric.woerle
CuriousDev,
A couple things first, I don't know if you've downloaded the PDF "Creating HTML5 Charts with WebFOCUS Language" yet, but I would recommend doing so. There is a lot of good stuff in there. I would recommend downloading the latest version. IBI uses a plug in for its JSCharts and I don't think they actually own any of the code (Just like they've integrated JQuery). So I found out that the 8.1.03 version of the document has a lot more documented then the 8.0.08 version, yet everything I've experimented that is not in the v8.0.08 documentation still works. If you were to find the original documentation from the JSChart plug in, then you might be able to find even more things that you can effect and get your hands on.
I would recommend looking at that, because if you're looking at changing the Legend, you probably want to update your tooltips as well.
As for your specific problem, I don't know if I have your exact solution, but if you only have 2 sort types, I'm assuming you are using that sorting to create 2 groups for your stack graph that you want to appear in a certain order. Going on the assumption that you only have two values, I would suggest not using a number sequence, but the actual text values that you would like to see in the Legend. You can then control which order they appear in by designating
BY HIGHEST CAR.BODY.SORTA
or
BY LOWEST CAR.BODY.SORTA
.
As I was looking over the PDF document, I didn't see any way to programmatically change the labels of the legend.
Another option you might have, but will be a lot more work is you could most likely build an annotation instead of using the legend. You would have complete control over what it says, but it would take more time to build.
Eric Woerle 8.1.05M Gen 913- Reporting Server Unix 8.1.05 Client Unix Oracle 11.2.0.2
April 20, 2015, 12:29 PM
Francis Mariani
quote:
I found out that the 8.1.03 version of the document has a lot more documented then the 8.0.08 version
Thanks for this tip Eric.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 20, 2015, 12:42 PM
CuriousDev
Martin Y your solution looks good but if i have 10 bodytypes and in future it will keep on increasing .i can't hard code it as your example.
WebFOCUS 8 Windows, All Outputs
April 20, 2015, 01:27 PM
eric.woerle
Welcome Francis.
I figured out that the 8.1.03 version of the document had more in it when I saw GavinL's post. I looked at it and went "Hey none of these commands are in my document".
I also had previously taken a look at the HTML generated when using JSCharts and noticed a call to a javascript library(tdgchart-min.js). I googled the library to find that someone else had developed it. The documentation on that site though wasn't very good. I found IBI's documentation to be much better. But maybe there is better documentation out there then what I found. And if so, maybe IBI hasn't documented everything available. There might be more that we can take advantage of.
Eric Woerle 8.1.05M Gen 913- Reporting Server Unix 8.1.05 Client Unix Oracle 11.2.0.2
April 20, 2015, 01:36 PM
MartinY
I was showing one way to do it using your example CuriousDev. It's sure that it must be adapted to your situation.
eric solution can also be one that you must consider but once again, we are not aware of all your specs and we're not here to do the job for you; just helping you finding a solution by giving you track to explore.
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007