In this section: |
GRAPH FILE request syntax is similar to TABLE FILE request syntax. To produce a chart instead of a tabular report, you need only substitute the command GRAPH for TABLE in the request. Thus, in some cases, you can produce charts by simply converting TABLE requests to GRAPH requests.
However, not every TABLE facility has a GRAPH counterpart, and there are some practical limitations on the amount of information that you can effectively display on a chart. When a TABLE request is converted in this manner, the phrases that make up the body of the request take on special meanings that determine the format and layout of the chart. The type of chart produced by a GRAPH FILE request depends on the display command used (SUM or PRINT), the sort phrases used (ACROSS, BY), and the LOOKGRAPH parameter setting.
The following shows the structure of a GRAPH FILE request:
GRAPH FILE filename
[HEADING ...]
{PRINT|SUM} field ... {BY|ACROSS} sortfield ...
[{WHERE|IF} expression ...[WHEN condition]] ...
[FOOTING ...]
ON GRAPH HOLD FORMAT JSCHART
[ON GRAPH SET LOOKGRAPH charttype] [ON GRAPH SET optional_parameter ...]
ON GRAPH SET STYLE * [*GRAPH_JS JSON properties *END] [*GRAPH_SCRIPT Legacy Graph API methods and properties *END] [StyleSheet declarations ] ENDSTYLE END
The following table describes each command :
Request Syntax | Description |
---|---|
GRAPH FILE filename | Required start of charting request. |
[HEADING ...] | Optional title for the chart. By default, the heading is placed on the HTML page above the chart. To embed the heading in the chart, include the ON GRAPH SET EMBEDHEADING ON command in the request. With this setting, the heading replaces the JSON chart title object. If you also include a JSON title object in the request, it will override the FOCUS heading. |
{PRINT|SUM} field ... | Required display command. Fields must be numeric. They can be real fields, virtual fields, or calculated values. PRINT displays individual field values, SUM aggregates them within the sort values. |
{BY|ACROSS} sortfield ... | Required sort phrase. |
[{WHERE|IF} expression ...[WHEN condition]] ... | Optional filtering criteria. |
[FOOTING ...] | Optional footing for the chart. By default, the footing is placed below the chart on the HTML page. To embed the footing in the chart, include the ON GRAPH SET EMBEDHEADING command in the request. With this setting, the footing replaces the JSON chart footnote object. If you also include a JSON footnote object in the request, it will override the FOCUS footing. |
ON GRAPH HOLD FORMAT JSCHART | Required SET command for creating HTML5 output. |
[ON GRAPH SET LOOKGRAPH charttype ON GRAPH SET AUTOFIT ON ON GRAPH SET GRAPHDEFAULT OFF ON GRAPH SET VZERO OFF ON GRAPH SET GRMERGE ADVANCED ON GRAPH SET GRMULTIGRAPH 0 ON GRAPH SET GRLEGEND 0 ON GRAPH SET GRXAXIS 1] | Optional SET commands. |
ON GRAPH SET STYLE * | Start of the style section of the request. The style section can include JSON blocks, legacy graph API blocks, and FOCUS StyleSheet declarations. They can appear in any order and there can be multiple blocks of each type. With conflicting properties, the last one in the style section of the request takes precedence. |
[*GRAPH_JS
JSON properties
*END] | Start and end of an optional JSON block of the style section. |
[*GRAPH_SCRIPT
Legacy graph methods and properties
*END] | Start and end of an optional legacy graph API block of the style section. These blocks are supported for backward compatibility, so that existing requests that contain these API calls can be converted to HTML5 charts without any changes except to include the ON GRAPH HOLD FORMAT JSCHART command. |
[StyleSheet declarations] | Optional FOCUS StyleSheet declarations. For information about StyleSheet declarations, see the Creating Reports manual. |
ENDSTYLE | End of the style section of the request. |
END | Required end of the request. |
The following request creates a vertical bar chart (ON GRAPH SET LOOKGRAPH VBAR). The y-axis represents the virtual field named CVAL, and the x-axis represents the sort field PRODUCT_CATEGORY:
-* Create virtual field
DEFINE FILE WFLITE
CVAL/D12.2= IF PRODUCT_CATEGORY GT 'M' THEN -COGS_US ELSE COGS_US;
END
-*Define default values for amper variables referenced in the request
-DEFAULTH &WF_STYLE_UNITS='PIXELS';
-DEFAULTH &WF_STYLE_HEIGHT='405.0';
-DEFAULTH &WF_STYLE_WIDTH='770.0';
-* GRAPH request starts
GRAPH FILE WFLITE
SUM CVAL
BY PRODUCT_CATEGORY
-*Required SET parameter for HTML5 output
ON GRAPH HOLD FORMAT JSCHART
-*Optional SET parameters
ON GRAPH SET GRAPHDEFAULT 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 VBAR
ON GRAPH SET AUTOFIT ON
-*Style section starts
ON GRAPH SET STYLE *
-*JSON block starts
*GRAPH_JS
mouseOverIndicator: {enabled: true,color: ' '},
introAnimation: {
enabled: true,
duration: 1000
}
*END
-*FOCUS StyleSheet declarations start
INCLUDE=ENDEFLT,$
TYPE=REPORT, PAGECOLOR = Green,$
-*Legacy graph API block starts
*GRAPH_SCRIPT
setUseNegativeDataTextColor(true);
setDataTextDisplay(true);
*END
ENDSTYLE
END
On the output:
The GRAPH request elements generally follow the same rules as their TABLE counterparts:
SET FILE=filename
You can specify any data source available to FOCUS, including joined or cross-referenced structures.
There are a few notable syntactical differences between TABLE and GRAPH. Specifically, the following restrictions apply:
Information Builders |