Applying Custom Styling to a Graph

In this section:

You can customize your graph using StyleSheets and SET commands. You can set the graph width and height, set fixed scales for the X and Y axes, enable the Graph Editor, and use Graph API calls to further customize your graph.

For details on customizing graph headings and footings, see Using Headings, Footings, Titles, and Labels.


Top of page

x
Setting the Graph Height and Width

How to:

The width (or horizontal axis) of each graph, which includes any surrounding text, is automatically set to 770 pixels. When setting the graph width, you should allow for the inclusion of any text required for the vertical axis and its labels along the left margin.

To maximize display space, you can limit the size of your labels through the use of either AS phrases or DECODE expressions.

The height (or vertical axis) of your graph is automatically set to 405 pixels.

The vertical axis is automatically set (VAUTO=ON) to cover the total range of plotted values. The height of the axis is set as high as possible (taking into consideration the presence of any headings or footings and the need to provide suitably rounded vertical class markers). The range is divided into intervals called "classes." The scale is normalized to provide class values rounded to the appropriate multiples and powers of 10 for the intervals plotted on the axis.



x
Syntax: How to Set the Graph Width
SET HAXIS=nn

where:

nn

Is a numeric value between 20 and 985 pixels.



x
Syntax: How to Set the Graph Height
SET VAXIS=nn

where:

nn

Is a numeric value between 20 and 518 pixels.


Top of page

x
Customizing Graphs Using SET Parameters

How to:

Reference:

The GRAPH environment includes a set of parameters that control the appearance of the graph and offer some additional control when you run the request.

For example, the BSTACK parameter enables you to specify that the bars on a bar graph are to be stacked rather than placed side by side.



x
Syntax: How to Use SET Parameters With GRAPH Requests

To set the parameters that control the GRAPH environment, use the appropriate variation of the SET parameter.

SET parameter=value,parameter=value...

For a list of supported GRAPH parameters, see Values and Functions of SET Parameters for Graphs.

Note:



Example: Using SET Parameters With GRAPH Requests

The following shows how to set the height (Y-axis) and width (X-axis) for a graph.

SET HAXIS=75,VAXIS=40
GRAPH FILE filename 
.
.
.
END


x
Reference: Values and Functions of SET Parameters for Graphs

Graph SET Parameter

Values

Parameter Function

3D
ON|OFF

When ON, a three-dimensional chart is produced. When OFF, a two-dimensional chart is produced. ON is the default.

AUTOTICK
ON|OFF

When ON, tick mark intervals are automatically set. ON is the default. (See also HTICK and VTICK.)

BARNUMB
ON|OFF

When ON, places the summary values at the ends of the bars on bar graphs or slices on pie graphs. OFF is the default.

BSTACK
ON|OFF

When ON, specifies that the bars on a bar graph are to be stacked rather than placed side by side. OFF is the default.

GRAPHEDIT
graphedit

Determines whether the Graph Editor is enabled at run time. For details, see Customizing Graphs With the Graph Editor.

GRID
ON|OFF

When ON, specifies that a grid is to be drawn on the graph at the horizontal and vertical class marks (see also VGRID). OFF is the default.

HAUTO
ON|OFF

When ON, specifies automatic scaling of the horizontal axis unless overridden by the user. If OFF, user must supply values for HMAX and HMIN. ON is the default.

HAXIS
20-770

Specifies the width in characters of the horizontal axis. This parameter can be adjusted for graphs generated offline. HAXIS is ignored for online displays since the width of the graph is automatically adjusted to the width of the display area.

HCLASS
nnn

Specifies the horizontal interval mark when AUTOTICK=OFF (see also HTICK).

HISTOGRAM
ON|OFF

When ON, a histogram is drawn instead of a curve when values on the horizontal axis are not numeric. OFF is the default.

HMAX
nnn

Specifies the maximum value on the horizontal axis when the automatic scaling is not used (HAUTO=OFF).

HMIN
nnn

Specifies the minimum value on the horizontal axis when the automatic scaling is not used (HAUTO=OFF).

HSTACK
ON|OFF

When ON, specifies that the bars on a histogram are to be stacked rather than placed side by side. OFF is the default.

HTICK
nnn

Specifies the horizontal axis tick mark interval when AUTOTICK is OFF (see also HCLASS).

LOOKGRAPH
option

Specifies the graph type. For more information, see Determining Graph Styles Using LOOKGRAPH.

PIE
ON|OFF

When ON, specifies that a pie graph is desired. OFF is the default.

VAUTO
ON|OFF

When ON, specifies automatic scaling of the vertical axis unless overridden by the user. If OFF, the user must supply values for VMAX and VMIN. ON is the default.

VAXIS
20-405

Specifies page length in lines. This parameter can be adjusted for graphs generated offline. VAXIS is ignored for online displays since the height of the graph is automatically adjusted to the display area.

VCLASS
nnn

Specifies the vertical interval mark when AUTOTICK=OFF (see also VTICK).

VGRID
ON|OFF

When ON, specifies that a grid is to be drawn on the graph at the horizontal and vertical class marks (see also GRID). OFF is the default.

VMAX
nnn

Specifies the maximum value on the vertical axis when the automatic scaling is not used (VAUTO=OFF).

VMIN
nnn

Specifies the minimum value on the vertical axis when the automatic scaling is not used (VAUTO=OFF).

VTICK
nnn

Specifies the vertical axis tick mark interval when AUTOTICK is OFF (see also VCLASS).

VZERO
ON|OFF

Determines whether values along the Y-axis are stored or ignored. If ON, missing data along the Y-axis is treated as zero. If OFF, missing data along the Y-axis is ignored and values are not stored in the plot matrix. OFF is the default.



x
Setting Fixed Scales for the X-Axis

How to:

The horizontal scale is automatically set to cover the total range of values to be plotted (HAUTO=ON). The range is divided into intervals called "classes." The scale is normalized to provide class values rounded to the appropriate multiples of 10 for the intervals plotted on the axis.

To assign fixed upper and lower limits (useful when producing a series of graphs where consistent scales are needed), you can turn off the automatic scaling mechanism and set new limit values by setting HAUTO=OFF.



x
Syntax: How to Set Fixed Scales for the X-Axis
SET HAUTO=OFF, HMAX=nn, HMIN=nn

where:

HAUTO

Is the automatic scaling facility. If HAUTO is ON, any values for HMAX and HMIN are overridden.

HMAX=nn

Sets the upper limit on the horizontal axis. The default is 0.

HMIN=nn

Controls the lower limit on the horizontal axis when HAUTO is OFF. The default is 0.

Note:


Top of page

x
Setting Fixed Scales for the Y-Axis

How to:

To give the vertical scale fixed upper and lower limits (useful when producing a series of graphs where consistent scales are needed), you can turn off the automatic scaling mechanism and set fixed limits using the SET VAUTO=OFF command.



x
Syntax: How to Set Fixed Scales for the Y-Axis
SET VAUTO=OFF, VMAX=nn, VMIN=nn

where:

VAUTO

Is the automatic scaling facility. If VAUTO is ON, any values for VMAX and VMIN are overridden.

VMAX=nn

Sets the upper limit on the vertical axis when VAUTO is OFF. The default is 0.

VMIN=nn

Controls the lower limit on the vertical axis when VAUTO is OFF. The default is 0.

Note:


Top of page

x
Customizing Graphs With the Graph Editor

How to:

The Graph Editor is an interactive graphical tool that allows you to modify a graph without having to edit the code manually. The Graph Editor applies and displays the changes you make to the graph.

When it is turned on in a procedure, you will be able to invoke the Graph Editor and make changes at run time without affecting your procedure.

For details on using the Graph Editor, see the Creating Charts With Graph Tools manual.



x
Syntax: How to Enable the Graph Editor

The SET GRAPHEDIT command must be placed before the GRAPH FILE command in a procedure.

SET GRAPHEDIT = graphedit

where:

graphedit

Determines whether the Graph Editor is enabled at run time. Possible values are:

ON activates the Graph Editor. A button is displayed in the upper-right corner of the window that contains the graph. Click this button to access the Graph Editor.

OFF is where the Graph Editor will not be enabled at run time and a Java-rendered graph is returned.

SERVER generates a server-side graph. A GIF graph is created on the Web server and the image is returned to the client in the browser.

This is the default.


Top of page

x
Customizing Graphs Using the Graph API (ON GRAPH SET GRAPHSTYLE *)

How to:

You can further enhance your graph output by manually adding API calls inside the ON GRAPH SET GRAPHSTYLE * and ENDSTYLE commands in the GRAPH request. When you save changes in the Graph Editor (if invoked from the Graph Assistant), the corresponding API calls will be written to the graph StyleSheet.

For reference information about the Graph API, see the WebFOCUS Graphics manual.



x
Syntax: How to Customize a Graph Using the Graph API
GRAPH FILE filename<graph commands>
ON GRAPH SET GRAPHSTYLE *
<API calls>
ENDSTYLE
[ON GRAPH SET STYLE *
<WEBFOCUS StyleSheet commands>
ENDSTYLE]
END

where:

filename

Specifies a data source for the graph.

API calls

For reference information about the Graph API, see the WebFOCUS Graphics manual.

WEBFOCUS StyleSheet commands

For details on StyleSheet commands, see Using an External Cascading Style Sheet.



Example: Customizing Graphs Using the Graph API

The following annotated example illustrates how to customize a graph using ON GRAPH SET GRAPHSTYLE *. The Graph API code is highlighted in the request.

   GRAPH FILE SALES
   SUM RETURNS
   RETAIL_PRICE
   ACROSS PROD_CODE AS 'Product Code'
   ON GRAPH SET GRAPHSTYLE *
1. setLegendMarkerPosition(4);
2. setO1LabelRotate(0);
3. setTitleString("Sales Report");
4. setTextJustHoriz(getTitle(),1);
   ENDSTYLE
   ON GRAPH SET STYLE *
   DEFMACRO=COND0001, MACTYPE=RULE, WHEN=RETURNS GT 4,$
   TYPE=DATA,MACRO=COND0001,ACROSSCOLUMN=RETURNS,COLOR=RED,$
   ENDSTYLE
   END

where:

  1. Displays legend text inside the legend marker.
  2. Displays the x-axis labels horizontally.
  3. Displays the title (Sales Report) without quotes.
  4. Centers the title.

The output is:


WebFOCUS