Examples of Interactive Java Output


Local Drill-Down Mode

The following example generates an HTML output file that runs the Graph applet. The applet automatically generates and displays drill-down graphs based on the element in the graph that was selected with a click of the left mouse button. In the example, note how variable roles are assigned in the VBAR3D statement.

This example is available in the Sample Library under the name GWBJALOC.

For further information, see Configuring the Local Drill-Down Mode on page 401.

 filename odsout  your-path-and-filename.htm  ;  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=odsout      style=gears;  title1 Company Sales, Mid Year;  proc gchart data=sales;     vbar3d region / sumvar=sales     group=year subgroup=state;  run; quit;  ods html close;  ods listing; 

Script Drill-Down Mode

The following example shows you how to implement the Script drill-down mode in the Graph applet or Map applet. The program generates a map of the United States that responds to drill-down actions by displaying abbreviated state names . In the example, note how PUT statements are used to insert JavaScript into the ODS output file.

This example is available in the Sample Library under the name GWBSCDRL.

For further information, see Configuring the Script Drill-Down Mode on page 407.

 /* Change the next two lines to run this program. */  filename odsout '  html-output-file  ' ;  libname maps '  map-data-library  ';  /* Create a data set that contains the US states. */  proc sql;  create table work.mydata as  select unique state from maps.us;  quit;  /* Add state abbreviations to the new data set. */  data work.mydata;   length Statename ;   set work.mydata;   Statename=trim(left(upcase(fipstate(state))));  run;  /* Specify the JAVA driver and the graph size. */  goptions reset=all device=java           xpixels=325 ypixels=225 ;  /* Specify the HTML output file, the script  */  /* drill-down mode, and the callback method. */  ods html file=odsout           parameters=("DRILLDOWNMODE"="Script"                       "DRILLFUNC"="MapDrill");  /* Specify a map title and generate the map. */  title1 "State Abbreviations";  proc gmap map=maps.us data=work.mydata all;     id state;     choro statename / nolegend;  run;  quit;  /* Close the HTML destination and */  /* open the listing destination.  */  ods html close;  ods listing;  /* Create the MapDrill script that is specified on */  /* the ODS HTML statement's DRILLFUNC parameter.   */  /* Write the script to the same file that contains */  /* the HTML output from the GMAP procedure.        */  data _null_ ;  file odsout mod; /* Modify the file rather than replacing it. */  put ' ' ;  put '<SCRIPT LANGUAGE="JavaScript">' ;  put 'function MapDrill(appletref)' ;  put '{' ;  put ' ' ;  put '/* Open an alert box to show the abbreviated state name. */ ' ;  put 'for(i = 2; i < MapDrill.arguments.length; i += 2)' ;  put '  {' ;  put '    if (MapDrill.arguments[i] == "G_DEPV,f")';  put '        alert(MapDrill.arguments[i+1]);' ;  put '  }' ;  put ' ' ;  put '}' ;  put '</SCRIPT>';  run ; 

URL Drill-Down Mode

The following example demonstrates URL drill-down mode.

This example is available in the SAS sample library under the name GWBURLDR. For further information, see Configuring the URL Drill-Down Mode on page 409.

 /* Enter the web-output-path. */  filename urldrill '  web-output-path  ';  filename sales '  web-output-path\sales.html  ';  filename central '  web-output-path\central.html  ';  filename south '  web-output-path\south.html  ';  filename west '  web-output-path\west.html  ';  /* Close the ODS listing destination to conserve resources. */  ods listing close;  /* Specify the device driver. */  goptions reset=global device=java;  /* Create the data set REGSALES. */  data regsales;     length Region State $ 8;     format Sales dollar8.;     input Region State Sales;  /* Initialize the link variable. */     length rpt ;  /* Assign values to the link variable. */  if Region='Central' then       rpt='href="central.html"';     else if Region='South' then       rpt='href="south.html"';     else if Region='West' then       rpt='href="west.html"';  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  ;  /* Open the HTML output file and specify the URL drill-down mode. */  ods html body=sales      path=urldrill      style=money      parameters=("drilldown"="url";  /* Create a chart that uses the link variable. */  title1 'Company Sales';  proc gchart data=regsales;     vbar3d region / sumvar=sales     patternid=midpoint     html=rpt;  run;  quit;  /* Create an HTML file for central sales drill-down. */  ods html body=central path=urldrill style=money;  /* Generate the first drill-down report. */  title1 'Central Sales';  proc print data=regsales noobs;     var state sales;     where region='Central';  run;  /* Create an HTML file for southern sales drill-down. */  ods html body=south path=urldrill style=money;  /* Generate the second drill-down report. */  title1 'Southern Sales';  proc print data=regsales noobs;     var state sales;     where region='South';  run;  /* Create an HTML file for western sales drill-down. */  ods html body=west  path=urldrill style=money;  /* Generate the third drill-down report. */  title1 'Western Sales';  proc print data=regsales noobs;     var state sales;     where region='West';  run;  quit;  /* Close the HTML destination and open the listing destination. */  ods html close;  ods listing; 

HTML Drill-Down Mode

The following example generates an HTML output file that displays the Map applet. The applet is configured for HTML drill-down mode, where drill-down URLs are dynamically generated based on the data in the graph element that was selected in the drill-down action. In the example, note how the value of the STATENAME variable is used to complete drill-down URLs.

This sample is available in the SAS Sample Library under the name GWBJAMAP.

For further information, see Configuring the HTML Drill-Down Mode on page 410.

 /* Close the ODS listing destination to conserve resources. */  ods listing close;  /* Specify a path and name for the HTML output file. */  ods html     file="your_web_path/your_HTML_file.htm"     parameters=("DRILLDOWNMODE"="HTML")     parameters=("DRILLPATTERN"='http://www.state.{&statename}.us')     parameters=("BACKCOLOR"="FFFFFF");  /* Specify the Java driver and set up customizations. */  goptions reset=all       device=java     cback=white           border          gunit=pct       htext=3           xpixels=500     ypixels=350  /* Specify colors for map regions. */  colors=(cxa5c09d,cxff358f,cx0431f8,cxffff00,cxd3a4ef,cxff8287,  cxd3a4ef,cxffc2d3,cx0431f8,cxffffc4,cx00edcf,cxcd7384,  cxf0eded,cx999797,cxa5c09d,cx008080,cxfabc46,cxff358f,  cx3f769a,cxff8600,cx45ab90,cxca4db0,cxf6d3a5,cx274776,  cxff72b0,cxb0c1f4,cx7dff88,cx4a97ed,cxed5662,cxffff81,  cx922e83,cxa5c09d,cxff358f,cx0431f8,cxffff00,cxd3a4ef,  cxff8287,cx5d55b3,cxffc2d3,cx0431f8,cxffffc4,cx00edcf,  cxcd7384,cxf0eded,cxca4db0,cx5d55b3,cx008080,cxfabc46,  cxd3a4ef,cx3f769a,cx5d55b3);  /* Create data for the graph. */  proc sql;     create table work.mydata as     select unique state from maps.us;     quit;     run;  data work.mydata;     length statename 20;     set work.mydata;  /* Place the state name in the data set. */     statename=trim(left(lowcase(fipstate(state))));  run;  title1     "Click on a state to go to that state's home page";  /* Generate the graph. */  proc gmap map=maps.us     data=work.mydata all;     id state;     choro statename / levels=1 discrete           coutline=black           nolegend           des='US Government Web Sites'           name='usgov';      run; quit;  /* Close the HTML output file and open the listing destination. */  ods html close;  ods listing; 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net