Chapter Contents

Previous

Next
The GANNO Procedure

Example 4: Using Annotate Graphics in a Drill-down Graph


Procedure features:
PROC GANNO statement option:
IMAGEMAP=
Sample library member: GR12N04

This example creates essentially the same Annotate data set used in Storing Annotate Graphics. It draws four colored squares and displays the data set as a single graphics output.

[IMAGE]

However, this time the example shows you how to use Annotate graphics to generate a drill-down graph (see About Drill-down Graphs). The example uses the HTML variable in the Annotate data set to specify linking information that defines each of the four squares as a hot zone. When the graph is viewed in a browser, you can click on a square to drill down to a related graph. For example, if you click on the green square, it drills down to a graph that confirms that you selected the green square.

[IMAGE]

The example uses the HTML device driver to generate the drill-down graph. To implement the drill-down capability, the Annotate data set uses the HTML variable to provide the linking information (see HTML Variable), and the GANNO procedure uses the IMAGEMAP= option to create an Imagemap data set. The presence of the HTML variable in the Annotate data set and the IMAGEMAP= option on the GANNO procedure causes the HTML device driver to generate an image map for the graph. It writes the image map to the file index.html, which the HTML device driver creates for displaying Web output (see Displaying Graphs on One Web Page (DEV=HTML)).

To prevent the HTML device driver from writing over the contents of index.html after the drill-down graph has been generated, the example switches to the GIF device driver. It then runs four GSLIDE procedures to generate the target output. Each GSLIDE procedure uses the NAME= option to name the graph it produces, ensuring that the GIF driver creates files named green.gif, blue.gif, red.gif, and gray.gif. These are the files that are referenced as targets by the strings that are specified for the Annotate data set's HTML variable.
 Note about code
/* define the output location */
filename webout 'path-to-Web-server';
   /* set the graphics environment */
goptions reset=global gunit=pct
         colors=(black blue green red);
 Note about code
   /* create Annotate data set */
data squares;
     length function style color $ 8
            html text $ 15;
     xsys='3'; ysys='3';

        /* draw the green square */
     color='green';
     function='move'; x=10; y=65; output;
     function='bar';  x=30; y=95; style='solid';
        html='href=green.gif'; output;

        /* label green square */
     function='label'; x=10; y=63; position='6';
        style='swissb'; size=2; text='Green'; output;

        /* draw the red square */
     color='red';
     function='move'; x=60; y=65; output;
     function='bar';  x=80; y=95;
        html='href=red.gif'; output;

        /* label red square */
     function='label'; x=60; y=63; position='6';
        style='swissb'; size=2; text='Red'; output;

        /* draw the blue square */
     color='blue';
     function='move'; x=10; y=15; output;
     function='bar';  x=30; y=45;
        html='href=blue.gif'; output;

        /* label blue square */
     function='label'; x=10; y=12; position='6';
        style='swissb'; size=2; text='Blue'; output;

        /* draw the gray square */
     color='gray';
     function='move'; x=60; y=15; output;
     function='bar';  x=80; y=45;
        html='href=gray.gif'; output;

        /* label gray square and add a footnote */
     function='label'; x=60; y=12; position='6';
        style='swissb'; size=2; text='Gray'; output;

        /* draw a blue frame */
     function='frame'; color='blue'; style='empty';
        /* set null link for background area in frame */
        html=''; output;
run;
 Note about code
/* set the graphics options for the web page */ 
goptions dev=html gsfname=webout
          xpixels=450 ypixels=400
          transparency; 
 Note about code
/* generate annotate graphics */ 
proc ganno annotate=squares
    imagemap=annomap
    description='Four squares'; 
run; 
 Note about code
/* change to gif driver for target output */
goptions dev=gif ftext=centb ctext=green;

/* generate the target output */
proc gslide wframe=4
   cframe=green name='green';
   note height=20;
   note height=10
        justify=center
       'Green Grass';
run;

goptions ctext=blue;
proc gslide wframe=4
   cframe=blue name='blue';
   note height=20;
   note height=10
        justify=center
       'Blue Sky';
run;

goptions ctext=red;
proc gslide wframe=4
   cframe=red name='red';
   note height=20;
   note height=10
        justify=center
       'Red Wine';
run;

goptions ctext=gray;
proc gslide wframe=4
   cframe=gray name='gray';
   note height=20;
   note height=10
        justify=center
       'Gray Mare';
run;
quit;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.