Enhancing Web Presentations with Chart Descriptions, Data Tips, and Drill-Down Functionality |
The HTML= and HTML_LEGEND= options can be used in a number of statements that generate graphs. These options are use to add drill-down links to Web presentations that are generated with the following device drivers:
GIF, JPEG, OR PNG
JAVA and ACTIVEX
JAVAMETA
In these Web presentations, the HTML= and HTML_LEGEND= options identify a variable that provides URLs for drill-down links. This variable is referred to as a link variable.
The HTML= option and HTML_LEGEND= options are also used to implement enhancements that run in the Metaview applet. In this case, the variables that are identified by the HTML= and HTML_LEGEND= options are referred to as enhancement variables because they do more than establish links.
Working with Link and Enhancement Variables |
To use link or enhancement variables in a Web presentation, you need to define those variables, add data to those variables, and then identify those variables in the HTML= option or the HTML_LEGEND= options, or both.
The following code fragment defines a link variable named RPT and assigns that variable a length of 40 characters.
data regsales; input Region State Sales; length RPT $40;
Be sure to define your link variable with a length that will be sufficient to contain your URLs (plus the HREF= option). There is no limit on the length of the variable.
The values of the link variable use the following syntax:
"HREF='URL<#anchor name'>"
The syntax is used in the following example:
RPT="href='reports.html#west' "
The most obvious method of adding these variables to your data set is to manually add them to the desired observations in your data set. This method is not practical or feasible in many cases, in which case you can use IF/THEN statements or variable substitution.
The following picture shows how link variables are assigned to a bar chart. The three bars represent regional sales for a company's central, southern, and western regions.
Links in Drill-Down Graphs
Each bar in the chart links to an anchor tag in an HTML file named reports.html. The anchor names in the linked file are "Central," "South," and "West." The following DATA step the IF/ THEN statement to assign values to the the link variable.
/* create data set REGSALES */ data regsales; length Region State $ 8; format Sales dollar8.; input Region State Sales; length rpt $80; /* the link dest. variable */ datalines; West CA 13636 West OR 18988 West WA 14523 Central IL 18038 Central IN 13611 Central OH 11084 Central MI 19660 South FL 14541 South GA 19022 ; /* assign HREF values to link dest. variable */ data regsales; set regsales; if Region="Central" then rpt="HREF='reports.htm#central'"; else if Region="South" then rpt="HREF='reports.htm#south'"; else if Region="West" then rpt="HREF='reports.htm#west'"; run; goptions reset=all device=ActiveX; ods listing close; ods html file="sales.htm"; /* create chart that uses link targets */ title "Regional Sales"; proc gchart data=regsales; vbar region / sumvar=sales html=rpt; run; /* create the link targets */ ods html file="reports.htm" anchor="south"; title "Southern Sales"; proc gchart data=regsales; where region="South"; vbar state /sumvar=sales; run; ods html anchor="central"; title "Central Sales"; proc gchart data=regsales; where region="Central"; vbar state /sumvar=sales; run; ods html anchor="west"; title "Western Sales"; proc gchart data=regsales; where region="West"; vbar state /sumvar=sales; run; quit; ods html close; ods listing;
You could use variable substitution to simplify the DATA step. The URLs used in the preceding program all use the same HTML file name, but the anchor differs depending on the value of the Region variable. You can concatenate the value of the Region variable to the common HTML file name to generate the drill-down URLs.
data regsales; set regsales; rpt="HREF='reports.htm#"||Region||"'"; run;
Links in GIF, JPEG, PNG, and SVG Presentations |
To add drill-down functionality to images generated with the GIF, JPEG, PNG, SVG, SVGT, SVGZ, and SVGVIEW device drivers, do one of the following:
Use the HTML= option with a SAS/GRAPH procedure to add drill-down functionality to the graph data elements.
Use the HTML_LEGEND= option with a SAS/GRAPH procedure to add drill-down functionality to the legend entries.
Use both the HTML= option and the HTML_LEGEND= option with a SAS/GRAPH procedure to add drill-down functionality to the legend entries.
Links in ACTXIMG and JAVAIMG Presentations |
To add drill-down functionality to an image created with the ACTXIMG or JAVAIMG device drivers, use the HTML= option as described in Adding Links with the HTML= and HTML_LEGEND= Options.
Links in ACTIVEX Presentations |
To add drill-down functionality to the ActiveX control created with the ACTIVEX device driver, use the HTML= option as described in Adding Links with the HTML= and HTML_LEGEND= Options.
Links in JAVA Presentations |
The Graph applet is a Java applet that provides drill-down functionality by default. The following code generates a graph using DEVICE=JAVA. When the Web page is displayed, drill-down functionality is enabled. The Graph applet retains the type and style of the initial graph for all the graphs in the presentation. The result is a sequence of three-dimensional, vertical bar charts that use the ODS style GEARS.
data sales; length Region $ 4 State $ 2; format Sales dollar8.; input Region State Sales Year Qtr; datalines; West CA 13636 1999 1 West OR 18988 1999 1 West CA 14523 1999 2 West OR 18988 1999 2 East MA 18038 1999 1 East NC 13611 1999 1 East MA 11084 1999 2 East NC 19660 1999 2 West CA 12536 1998 1 West OR 17888 1998 1 West CA 15623 1998 2 West OR 17963 1998 2 East NC 17638 1998 1 East MA 12811 1998 1 East NC 12184 1998 2 East MA 12760 1998 2 ; goptions reset=all device=java; ods listing close; ods html file="vbarweb.htm" style=gears; title "Company Sales, Mid Year"; proc gchart data=sales; vbar3d region / sumvar=sales group=year subgroup=state; run; quit; ods html close; ods listing;
The initial graph displayed by this example is shown in the example below. In this graph, REGION is the independent variable, and SALES is the dependent variable.
SALES is the dependent variable.
REGION is the independent variable.
STATE is the subgroup variable.
YEAR is the group variable.
Clicking the bar segment labeled East generates the graph shown in Graph Applet: Level 2. The Level 2 drill-down graph retains the dependent variable SALES. The group variable YEAR is promoted to the independent variable role. The drill-down action creates one bar segment for each unique value of YEAR.
SALES is the dependent variable.
YEAR is the independent variable.
Clicking the bar segment labeled 1998 generates the graph shown in Graph Applet: Level 3. The Level 3 drill-down graph retains the dependent variable SALES. The subgroup variable STATE is promoted to the independent variable role. STATE is the last variable that can appear as an independent variable. The drill-down action creates one bar segment for each unique value of STATE.
SALES is the dependent variable.
STATE is the independent variable.
Links in Metaview Applet Presentations |
To generate drill-down presentations for the Metaview applet use either the HTML= or the HTML_LEGEND= options or both and an enhancement variable, as introduced in Adding Links with the HTML= and HTML_LEGEND= Options.
Links in Animated GIF Presentations |
SAS/GRAPH does not directly support drill-down functionality for animated GIFs. To enable drill-down functionality from an animated GIF, use any third-party tools that are available to you. You can make the entire image a hotspot by including the <IMG> tag inside an <A HREF=> tag.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.