Focal Point
[SOLVED] Graph SORT field in legend with NOPRINT

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

January 15, 2015, 03:19 PM
BI_Developer
[SOLVED] Graph SORT field in legend with NOPRINT
Hello

I am developing a bar graph and I need legend (which is data) in a specific order. So, I used a DEFINE sort field in my processing and assigned the needed order and added it with a NOPRINT to graph request. Even though its NOPRINT, legend is showing the numbers from SORT_CNTRY instead of the name from COUNTRY.
DEFINE FILE CAR
SORT_CNTRY/I1 = IF COUNTRY EQ 'FRANCE' THEN 1 ELSE
		    IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE
		    IF COUNTRY EQ 'JAPAN' THEN 3 ELSE
		    IF COUNTRY EQ 'ITALY' THEN 4 ELSE 5;
END

GRAPH FILE CAR
SUM
	SALES AS ''
BY HIGHEST SORT_CNTRY NOPRINT
BY COUNTRY AS ''
ACROSS BODYTYPE AS ''
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
ENDSTYLE
END


Please suggest.

Thanks

This message has been edited. Last edited by: BI_Developer,


WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
January 16, 2015, 01:53 AM
Ram Prasad E
You can try below one.
DEFINE FILE CAR
COUNTRY_C/A1=IF COUNTRY EQ 'FRANCE' THEN '1' ELSE IF COUNTRY EQ 'JAPAN' THEN '2' ELSE '3';
END
GRAPH FILE CAR
SUM
	SALES AS ''
ACROSS BODYTYPE 
BY COUNTRY_C
BY COUNTRY 
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ADVANCED
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 2
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
ON GRAPH SET STYLE *
TYPE=DATA, COLUMN=COUNTRY_C, COLOR='WHITE', $
ENDSTYLE
END



WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
January 16, 2015, 10:28 AM
RRKen
I think JSCHART is available only version 8 and later? HTML5 compatible browser as well. I can run that in 8.0.09 I have in test but not 7.7.03 I have in production.


8.2.03 AIX Client Windows Tomcat
DB2, Terradata, SQL, Oracle
January 20, 2015, 11:53 AM
BI_Developer
Any suggestions please? I am still having problem with this.
I am getting multiple charts with suggested code.


WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
January 20, 2015, 12:51 PM
<nick z>
Hi,
You can concatinate 2 fields:
 

DEFINE FILE CAR
SORT_CNTRY/I1 = IF COUNTRY EQ 'FRANCE' THEN 1 ELSE
		    IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE
		    IF COUNTRY EQ 'JAPAN' THEN 3 ELSE
		    IF COUNTRY EQ 'ITALY' THEN 4 ELSE 5;

NEW_SORT/A1=EDIT(SORT_CNTRY);
NEW_COUNTRY/A50=NEW_SORT|':'|COUNTRY;
END


GRAPH FILE CAR
SUM
	SALES AS ''
BY HIGHEST NEW_COUNTRY
ACROSS BODYTYPE AS ''
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setPlace(true);
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");

ENDSTYLE
END
 


would that work?

Thanks.
Nick.
January 20, 2015, 12:56 PM
Francis Mariani
I think it's the GRMERGE setting that causes multiple graphs. From the doc:

quote:
The GRMERGE parameter generates a three-dimensional graph that reflects all output data from a request containing multiple sort fields, or creates separate graphs that collectively reflect all output data. When GRMERGE is OFF, a request containing both a BY and an ACROSS phrase generates two graphs. When it is ON, one graph results.

The syntax is:

SET GRMERGE = {ON|OFF|ADVANCED}
where:

ON - Generates a single three-dimensional graph that reflects all output data. ON is the default.

OFF - Generates separate graphs that collectively reflect all output data.

ADVANCED - Turns on the advanced merge option. This option uses three parameters to determine how to merge the graphs:

GRMULTIGRAPH, which specifies how many sort fields to use to create multiple graphs.
GRLEGEND, which specifies how many sort fields to place on the graph legend.
GRXAXIS, which specifies how many sort fields to display on the X-axis. GRXAXIS must be at least 1 in order to plot the graph. A value greater than one creates nested X-axes.

Note: The sum of the sort fields used by GRMULTIGRAPH, GRLEGEND, and GRXAXIS must equal the number of sort fields in the graph request.



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
January 20, 2015, 01:26 PM
BI_Developer
Hello Nick

Thank u for posting.

I tried this and got it to work before posting my question here. User does not like to see concatenated numbers.


quote:
Originally posted by nick z:
Hi,
You can concatinate 2 fields:
 

DEFINE FILE CAR
SORT_CNTRY/I1 = IF COUNTRY EQ 'FRANCE' THEN 1 ELSE
		    IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE
		    IF COUNTRY EQ 'JAPAN' THEN 3 ELSE
		    IF COUNTRY EQ 'ITALY' THEN 4 ELSE 5;

NEW_SORT/A1=EDIT(SORT_CNTRY);
NEW_COUNTRY/A50=NEW_SORT|':'|COUNTRY;
END


GRAPH FILE CAR
SUM
	SALES AS ''
BY HIGHEST NEW_COUNTRY
ACROSS BODYTYPE AS ''
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setPlace(true);
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");

ENDSTYLE
END
 


would that work?

Thanks.
Nick.



WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
January 20, 2015, 01:30 PM
BI_Developer
Hello Franics

I tried various combinations but did not work.
quote:
Originally posted by Francis Mariani:
I think it's the GRMERGE setting that causes multiple graphs. From the doc:

quote:
The GRMERGE parameter generates a three-dimensional graph that reflects all output data from a request containing multiple sort fields, or creates separate graphs that collectively reflect all output data. When GRMERGE is OFF, a request containing both a BY and an ACROSS phrase generates two graphs. When it is ON, one graph results.

The syntax is:

SET GRMERGE = {ON|OFF|ADVANCED}
where:

ON - Generates a single three-dimensional graph that reflects all output data. ON is the default.

OFF - Generates separate graphs that collectively reflect all output data.

ADVANCED - Turns on the advanced merge option. This option uses three parameters to determine how to merge the graphs:

GRMULTIGRAPH, which specifies how many sort fields to use to create multiple graphs.
GRLEGEND, which specifies how many sort fields to place on the graph legend.
GRXAXIS, which specifies how many sort fields to display on the X-axis. GRXAXIS must be at least 1 in order to plot the graph. A value greater than one creates nested X-axes.

Note: The sum of the sort fields used by GRMULTIGRAPH, GRLEGEND, and GRXAXIS must equal the number of sort fields in the graph request.



WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active
January 20, 2015, 02:53 PM
Dan Satchell
This really only works for a limited number of known values, but you can use this trick of placing spaces in front of the values. The spaces get compressed in the output.

 
DEFINE FILE CAR
SORT_CNTRY/A15 = IF COUNTRY EQ 'FRANCE'  THEN '    FRANCE' ELSE
	         IF COUNTRY EQ 'ENGLAND' THEN '   ENGLAND' ELSE
	         IF COUNTRY EQ 'JAPAN'   THEN '  JAPAN'    ELSE
	         IF COUNTRY EQ 'ITALY'   THEN ' ITALY'     ELSE COUNTRY ;
END
-*
GRAPH FILE CAR
SUM	SALES AS ''
BY HIGHEST SORT_CNTRY
ACROSS BODYTYPE AS ''
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
ENDSTYLE
END

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
January 20, 2015, 03:40 PM
<nick z>
What you can do is add extra legend labels and give them any text you like.
You would then start your legend from that extra legend markers.
Here is a sample code.
I basically colored the extra legend markers to be the same color as each series from the stylesheet:

  
DEFINE FILE CAR
SORT_CNTRY/I1 = IF COUNTRY EQ 'FRANCE' THEN 1 ELSE
		    IF COUNTRY EQ 'ENGLAND' THEN 2 ELSE
		    IF COUNTRY EQ 'JAPAN' THEN 3 ELSE
		    IF COUNTRY EQ 'ITALY' THEN 4 ELSE 5;
END

GRAPH FILE CAR
SUM
	SALES AS ''
BY HIGHEST SORT_CNTRY NOPRINT
BY COUNTRY AS ''
ACROSS BODYTYPE AS ''
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET HTMLENCODE ON
ON GRAPH SET GRAPHDEFAULT OFF
ON GRAPH SET VZERO OFF
ON GRAPH SET HAXIS 900
ON GRAPH SET VAXIS 600
ON GRAPH SET UNITS PIXELS
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET GRMERGE ON
ON GRAPH SET GRMULTIGRAPH 0
ON GRAPH SET GRLEGEND 1
ON GRAPH SET GRXAXIS 1
ON GRAPH SET GRAPHSTYLE *
setTemplateFile("/images/tdg/template/IBISouthWestern.txt");
setLegendSeriesStart(5);
setMarkerShape(getAllSeries(),1);
setTextString(getLegendLabel(0),"W GERMANY");
setDisplay(getLegendLabel(0),true);
setFillColor(getLegendLabelMarker(0),new Color(158,144,188));
setBorderColor(getLegendLabelMarker(0),new Color(158,144,188));

setTextString(getLegendLabel(1),"ITALY");
setDisplay(getLegendLabel(1),true);
setFillColor(getLegendLabelMarker(1),new Color(255,243,172));
setBorderColor(getLegendLabelMarker(1),new Color(255,243,172));

setTextString(getLegendLabel(2),"JAPAN");
setDisplay(getLegendLabel(2),true);
setFillColor(getLegendLabelMarker(2),new Color(106,189,187));
setBorderColor(getLegendLabelMarker(2),new Color(106,189,187));

setTextString(getLegendLabel(3),"ENGLAND");
setDisplay(getLegendLabel(3),true);
setFillColor(getLegendLabelMarker(3),new Color(240,159,97));
setBorderColor(getLegendLabelMarker(3),new Color(240,159,97));

setTextString(getLegendLabel(4),"FRANCE");
setDisplay(getLegendLabel(4),true);
setFillColor(getLegendLabelMarker(4),new Color(195,218,125));
setBorderColor(getLegendLabelMarker(4),new Color(195,218,125));

ENDSTYLE
END



To make sure your colors match you can remove setLegendSeriesStart(5);
January 20, 2015, 03:44 PM
BI_Developer
Dan's solutions worked as I have max 5 values.
Thanks Nick for letting me know of a different way as well..


WF 8.2.01 APP STUDIO
PDF,HTML,EXL2K,Active