IBI WebFOCUS - Formatting Graphs using reusable fex file and stylesheet

Some times while creating a graph using web focus code we face problems in formatting the graph. For example – graph title, Font size, font name, Y-axis title, legend position, label rotation etc. To save the time in searching these things the below codes will be very useful.

We just need to set the values as we want in the graph in set_values.fex and we can include the set_values.fex file to the fex file in our code before GRAPH FILE FILENAME command.

And second fex reuse.fex we need to include after ON GRAPH SET GRAPHSTYLE * command (you can also put the reuse.fex codes to reuse.sty and include it at the same position).

Code for set_values.fex:

-*Set the value for the graph Title
-DEFAULT &GRAPH_NAME='XYZ';

-*Set the value for X-axis Title
-DEFAULT &O1_TITLE='ABC';

-*Set the value for Y1-Axis title
-DEFAULT &Y1_TITLE='ABC';

-*Set the font Name for X-axis
-DEFAULT &O1_label_n='Arial';

-*Set the font Size for X-axis
-DEFAULT &O1_label_s=10;

-*Set the font Rotation for X-axis
-DEFAULT &O1_label_rot=1;

-*Set staggered value as true if you want staggered otherwise give false for X-axis
-DEFAULT &O1_label_sta='true';

-*Set the font Name for Y1-axis
-DEFAULT &Y1_label_n='Arial';

-*Set the font size for Y1-axis
-DEFAULT &Y1_label_s=10;

-*Set the font Name for Legend
-DEFAULT &LEGEND_FONT='Arial';

-*Set the font size for Legend
-DEFAULT &LEGEND_SIZE=10;

-*Set the legend position for the graph you can give values as 1,2,3 or 4 based on your requirement
-DEFAULT &LEGEND_POSITION=1;

-*Set the font Name for Footnote
-DEFAULT &FOOT_FONT='Arial';

-*Set the font size for Footnote
-DEFAULT &FOOT_SIZE=10;

-*SET &FLG_Y2 as 'Y' if you want Y2 axis also in your Graph
-DEFAULT &FLG_Y2='N';

-*Set the value for Y2-Axis title
-DEFAULT &Y2_TITLE='ABC';

-*Set the font Name for Y2-axis
-DEFAULT &Y2_label_n='Arial';

-*Set the font size for Y2-axis
-DEFAULT &Y2_label_s=10;

-*Set &LINE_WIDTH as 1,2,3,4 etc. if you are using line in the graph to set the width of the line
-DEFAULT &LINE_WIDTH='';

-*Set the &LINE_SERIES as 0,1,2,3 etc. for making the styling on the graph
-DEFAULT &LINE_SERIES=1;

-*Set &MARKER_SHAPE as 1,2,3,4 etc. to give the shape to marker based on the requirement

-DEFAULT &MARKER_SHAPE=1;
*****************************************************

Code for reuse.fex:

-*After Setting all the above parameter the user can include this fex file in his fex


-*----------For Setting the graph name-------------------
setTextString(getTitle(),"&GRAPH_NAME.EVAL");

-*----------For Setting X-axis Title---------------------
setTextString(getO1Title(),"&O1_TITLE.EVAL");

-*----------For Setting Y1-axis Title---------------------
setTextString(getY1Title(),"&Y1_TITLE.EVAL");

-*----------For X-axis labels----------------------------
setFontName(getO1Label(),"&O1_label_n.EVAL");
setFontSizeInPoints(getO1Label(), &O1_label_s.EVAL);
setLabelStagger(getO1Label(),&O1_label_sta.EVAL);

-*----------For X-axis labels Rotation--------------------
setTextRotation(getO1Label(),&O1_label_rot.EVAL);

-*----------For Y1-axis labels----------------------------
setFontName(getY1Label(),"&Y1_label_n.EVAL");
setFontSizeInPoints(getY1Label(), &Y1_label_s.EVAL);

-IF &FLG_Y2 EQ 'N' GOTO SKIP_Y2;
-*----------For Setting Y2-axis Title---------------------
setTextString(getY1Title(),"&Y2_TITLE.EVAL");

-*----------For Y2-axis labels----------------------------
setFontName(getY1Label(),"&Y2_label_n.EVAL");
setFontSizeInPoints(getY1Label(), &Y2_label_s.EVAL);

-SKIP_Y2

-*-----------Formatting Legends--------------------------
setFontName(getLegendText(),"&LEGEND_FONT.EVAL");
setFontSizeAbsolute(getLegendText(), true);
setFontSizeInPoints(getLegendText(),&LEGEND_SIZE.EVAL);
setPlaceResize(getLegendText(),0);
setFontStyle(getLegendText(),2);

-*-----------Legends Position-----------------------------
setLegendPosition(1);

-*-----------Formatting Footnote--------------------------
setFontName(getFootnote(),"&FOOT_FONT.EVAL");
setFontSizeAbsolute(getFootnote(), true);
setFontSizeInPoints(getFootnote(), &FOOT_SIZE.EVAL);
setPlaceResize(getFootnote(), 0);

-IF &LINE_WIDTH EQ '' GOTO SKIP_WIDTH;
setLineWidth(getSeries(&LINE_SERIES.EVAL),&LINE_WIDTH.EVAL); 
setMarkerShape(getSeries(&LINE_SERIES.EVAL),&MARKER_SHAPE.EVAL);
-SKIP_WIDTH

******************************************************************************

Any suggestions are always welcome. Happy Coding in WebFOCUS.

Comments

Popular posts from this blog

IBI WebFOCUS - Functions available and syntax to use

IBI WebFOCUS - Difference (Preference) between Join and Match:

IBI WebFOCUS - Testing and Debugging in WebFOCUS codes