<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd">

 <%title="Using the Google visualisation API with R"%>
 
<html>
  <%@include file="src/simpleHead.rsp"%>
  
  <body>
    <%@include file="src/simpleHeader.rsp"%>
    <%require(googleVis)%>
    <h2>
      Welcome
    </h2>
    Welcome
    to <a href="http://code.google.com/p/google-motion-charts-with-r/"><b>googleVis</b></a> 
    version <%=packageDescription("googleVis")$Version%> by:
    <a href="mailto:markus.gesmann@gmail.com">Markus Gesmann</a>
    and <a href="mailto:decastillo@gmail.com">Diego de Castillo</a>
    <h2>
      Introduction
    </h2> 
    <p>
     <tt>googleVis</tt> is a package
     for <a href="http://www.r-project.org">R</a> which provides
     functions to visualise data in R with
     the <a href="http://code.google.com/apis/visualization/documentation/gallery.html">Google
     Visualisation API.</a> 
     <BR>
     Please read 
     Google's <a href="http://code.google.com/apis/visualization/terms.html">terms
     of use</a> and data policy. 
     <BR>The visual output will be rendered in your browser using Flash. 
    </p>
    <p>    
      Type <tt>?googleVis</tt> in the R console to see the overall documentation
      and <tt>vignette('googleVis')</tt> to access the package
      vignette.
      <BR>
      This page provides some examples of the package. You find more
      as part of the demo; to execute the demo type into the R
      console: <tt>demo(googleVis)</tt>.
    </p>
    <h2>
      Embedding googleVis charts into your web page with <a href="/">R.rsp</a>
    </h2>
    <p>
      The R
      package <tt><a href="http://cran.r-project.org/package=R.rsp">R.rsp</a></tt>
      provides a lightweight web-server which we are using here to
      display these pages. Additionally the <tt>R.rsp</tt>
      package allows us to dynamically generate documents into
      static content using R Server Pages. This means we can mix html and R 
      code to create content on the fly. 
    </p>
    <p>
      For more information
      on <tt>R.rsp</tt> see <a href="/">here.</a>
    </p>
    <h2>Examples with googleVis</h2>
    You can embed googleVis charts quite easily in your rsp page.
    <p>
      For example 
      <pre>
&lt;%=gvisGeoMap(Exports, locationvar='Country',
numvar='Profit',options=list(height=350,
dataMode='regions'))$html$chart%&gt; 
      </pre> 
      gives you a <b>Geo Map</b>:
    </p>
    <p>
      <%=gvisGeoMap(Exports, locationvar='Country', numvar='Profit',options=list(height=350, dataMode='regions'))$html$chart%>
      See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/geomap.html">Google
      Geo Map API</a>  
    </p>
    <p>
      A Google <b>Map</b> can be create e.g. via 
      <pre>
&lt;%=gvisMap(Andrew, "LatLong" , "Tip", options=list(showTip=TRUE,
showLine=TRUE, enableScrollWheel=TRUE,  mapType='terrain',
useMapTypeControl=TRUE))$html$chart%&gt;
     </pre> 
    </p>
    <p>
<%=gvisMap(as.list(Andrew), "LatLong" , "Tip",  options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE, mapType='terrain', useMapTypeControl=TRUE))$html$chart%>
     See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/map.html">Google
	Map API</a>  
    </p>
   <p>
      For a <b>Motion Chart</b> we would write something like 
      <pre>
&lt;%=gvisMotionChart(Fruits, idvar="Fruit", timevar="Year",
options=list(width=600, height=500))$html$chart%&gt;
      </pre> 
    </p>
    <p>
      <%=gvisMotionChart(Fruits, idvar="Fruit", timevar="Year",  options=list(width=600, height=500))$html$chart%>
      See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/motionchart.html">Google
	Motion Chart API</a>  
    </p>
    <p>
      A <b>Tree Map</b> can be generated with 
      <pre>
&lt;%=gvisTreeMap(Regions, idvar="Region", parentvar="Parent",
sizevar="Val", colorvar="Fac", options=list(width=600, height=500,
showScale=TRUE, fontSize=16))$html$chart%&gt;
      </pre> 
    </p>
    <p>
      <%=gvisTreeMap(Regions, "Region", "Parent", "Val", "Fac", options=list(width=600, height=500,  showScale=TRUE, fontSize=16))$html$chart%>
      See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/treemap.html">Google
	Tree Map API</a>  
    </p>
    <p>
      To display a <b>Table</b> we write 
      <pre>
&lt;%=gvisTable(Exports, options=list(width=600, height=300))$html$chart%&gt;
     </pre> 
    </p>
    <p>
      <%=gvisTable(Exports, options=list(width=600, height=300))$html$chart%>
      See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/table.html">Google
      Table API</a>  
    </p>


    <p>
      For an <b>Annotated Time Line</b> an example could look like 
      <pre>
&lt;%=gvisAnnotatedTimeLine(Stock, datevar="Date", numvar="Value",
idvar="Device",  titlevar="Title", annotationvar="Annotation",
options=list(displayAnnotations=TRUE, width=600, height=350))$html$chart%&gt; 
     </pre> 
    </p>
    <p>
      <%=gvisAnnotatedTimeLine(Stock, datevar="Date", numvar="Value",  idvar="Device", titlevar="Title", annotationvar="Annotation",  options=list(displayAnnotations=TRUE, width=600, height=350))$html$chart%>
      See also: <a href="http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html">Google
      Annotated Time Line API</a>  
    </p>

    <p>
      We hope these examples show you how you can generate content
      with functions from the <!-- <tt>R.rsp</tt> and --> <tt>googleVis</tt>
      packages.
    </p>
    <p>
    </p>
    <small>
      <em>If a page is loading "forever", that is, the internal web server seems to be stuck, try to press ENTER in the main R window.  This normally helps.</em>
    </small>
    


    <%@include file="src/simpleFooter.rsp"%>
  </body>
</html>


