Embed Interactive Charts from R/Google Visualization API into Web Page Generated with Emacs-Org-Babel

Table of Contents

1 Introduction

The R package googleVis provides a R interface into the Google Visualisation API, the latter of which offers interactive charts that can be embedded into web pages. Using Emacs-Org-Babel mode, we can easily generate a web page with embedded interactive chart based on a R data frame object. Following is an example R source code block:

#+begin_src R :exports both :results output html
  library(googleVis)
  data(Fruits)
  m <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")
  print(m, 'chart')
#+end_src

You would then see the embedded interactive chart in the html file exported from Emacs-Org mode via a web server.

If you want to view the chart (a Flash object) in a local file, as you usually do when editing an .org file, you would need to change your Flash security settings according to this solution quoted below by Tony Breyal:

  1. Go to http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
  2. Click on the dropbox which says 'Edit location' and choose 'add location'
  3. Click 'browse for folder'
  4. Choose the folder in which you saved your html file
  5. Click OK

Date: 2012-07-18 16:38:45 EDT

Author: Feiming Chen

Org version 7.7 with Emacs version 23