Sample 49254: Create an animated SVG graph using the GMAP, GCHART, GPLOT, and GREPLAY procedures
Beginning with SAS® 9.4, you can create animated graphs in scalable vector graphics (SVG) format. New options available in the OPTIONS statement enable you to have a wide range of control over the SVG animation. Note that in order to take advantage of SVG graphics, you must use an SVG-enabled web browser to view the graphics output.
The sample code on the Full Code tab uses a combination of PROC GMAP, PROC GCHART, PROC GPLOT, and PROC GREPLAY to create an animated graph where the GCHART and GPLOT output fades in and out of the map created by PROC GMAP.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Support for animated SVG graphics output is new starting with SAS 9.4. You must be running SAS 9.4 in order to run this sample code.
%macro delcat(catname);
%if %sysfunc(cexist(&catname))
%then %do;
proc greplay nofs igout=&catname;
delete _all_;
run;
quit;
%end;
%mend delcat;
%delcat(work.gseg)
ods _all_ close;
ods listing;
/* Create sample data for use with */
/* PROC GCHART and PROC GPLOT. */
data bardata;
input x y;
datalines;
1 3
2 5
3 8
4 12
;
run;
/* Set the size of the SVG graph */
options svgheight='400px' svgwidth='600px';
/* Set the DEVICE= option to SVG */
goptions reset=all device=svg border nodisplay
gunit=pct htitle=5 htext=2 ftext="Arial";
pattern1 v=me;
title1 "Watch chart and plot fade into view";
proc gmap data=maps.us map=maps.us;
id state;
choro state / levels=1 nolegend coutline=graycc
des="" name="gmap";
run;
quit;
title1;
footnote1;
goptions noborder gunit=pct htext=4 ftext="arial/bo" cback=affffff00;
pattern1 v=s c=red;
axis1 label=none value=none major=none minor=none style=0;
axis2 color=blue label=none offset=(7,7) value=(color=blue);
proc gchart data=bardata;
vbar x / discrete
type=sum sumvar=y
descending
raxis=axis1
maxis=axis2
width=9
space=5
coutline=blue
noframe
des=""
name="gchart";
run;
quit;
axis2 color=blue label=none minor=none;
symbol font="symbol" c=red value='c5'x h=8 i=join width=1 ;
proc gplot data=bardata;
plot y*x / noframe name="gplot" haxis=axis2 vaxis=axis2;
run;
quit;
/* Use PROC GREPLAY to create a custom three-panel template */
proc greplay tc=work.tempcat nofs;
tdef overlay des="Three panel overlayed template"
1/llx=0 lly=0
ulx=0 uly=100
urx=100 ury=100
lrx=100 lry=0
2/llx=10 lly=25
ulx=10 uly=75
urx=45 ury=75
lrx=45 lry=25
3/llx=45 lly=25
ulx=45 uly=75
urx=80 ury=75
lrx=80 lry=25
;
run;
quit;
goptions display;
/* Set system options to control the SVG animation */
options animate=start animduration=2 svgfadein=3 svgfadeout=3
svgautoplay animloop=yes nodate nonumber noanimoverlay;
/* Use PROC GREPLAY with the ODS HTML5 statement */
/* to create the final animated graph. */
ods _all_ close;
ods html5 file='svg_greplay.html' options(svg_mode='inline');
proc greplay tc=work.tempcat template=overlay igout=gseg nofs;
replay gmap;
tplay 1:gmap 2:gchart;
tplay 1:gmap 2:gchart 3:gplot;
run;
quit;
ods _all_ close;
ods listing;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample illustrates how to create an animated SVG graph using the GMAP, GCHART, GPLOT, and GREPLAY procedures.
Date Modified: | 2013-07-02 08:58:28 |
Date Created: | 2013-02-22 15:12:35 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.4 TS1M0 | |
Microsoft Windows Server 2003 for x64 | 9.4 TS1M0 | |
Microsoft Windows Server 2008 | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 TS1M0 | |
Microsoft Windows XP Professional | 9.4 TS1M0 | |
Windows 7 Enterprise 32 bit | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 TS1M0 | |
Windows 7 Home Premium 32 bit | 9.4 TS1M0 | |
Windows 7 Home Premium x64 | 9.4 TS1M0 | |
Windows 7 Professional 32 bit | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 TS1M0 | |
Windows 7 Ultimate 32 bit | 9.4 TS1M0 | |
Windows 7 Ultimate x64 | 9.4 TS1M0 | |
Windows Vista | 9.4 TS1M0 | |
Windows Vista for x64 | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 TS1M0 | |
HP-UX IPF | 9.4 TS1M0 | |
Linux for x64 | 9.4 TS1M0 | |
Solaris for x64 | 9.4 TS1M0 | |