## Please note that by default the googleVis plot command
## will open a browser window and requires Flash and Internet
## connection to display the visualisation.
Fruits
## timevar Year
M1 <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")
str(M1)
## print.gvis, will concatenate the list into a one long string
M1
plot(M1)
## Combine with another chart, e.g. table
tbl <- gvisTable(Fruits, options=list(height=220))
Mtbl <- gvisMerge(M1, tbl)
plot(Mtbl)
## Usage of date variable
M2 <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Date",
date.format = "%Y%m%d")
plot(M2)
## Options: no side panel on the right
M3 <- gvisMotionChart(Fruits,"Fruit","Year",
options=list(showSidePanel=FALSE))
plot(M3)
## Options: trails un-ticked
M4 <- gvisMotionChart(Fruits, "Fruit", "Year",
options=list(state='{"showTrails":false};'))
plot(M4)
## Using information from the advanced state settings
##
## In the browser window you can change some of displaying settings,
## e.g. the level of opacity of not selected items.
## Copy and paste the state string from the 'Advanced' tab into R
## and you can add it to your list of options:
myStateSettings <-'
{"xZoomedDataMax":111,"dimensions":{"iconDimensions":["dim0"]},
"colorOption":"2","xZoomedIn":false,"yZoomedDataMax":91,
"sizeOption":"5","yZoomedIn":false,"xLambda":1,"time":"2008",
"yZoomedDataMin":71,"iconType":"BUBBLE","showTrails":true,
"xAxisOption":"3","duration":{"timeUnit":"Y","multiplier":1},
"playDuration":15000,"nonSelectedAlpha":0,"iconKeySettings":[],
"orderedByY":false,"uniColorForNonSelected":false,"orderedByX":false,
"xZoomedDataMin":81,"yLambda":1,"yAxisOption":"4"}
'
M5 <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(state=myStateSettings))
plot(M5)
## For more information see:
## http://code.google.com/apis/chart/interactive/docs/gallery/motionchart.html#Motion_Chart_initial_state
Run the code above in your browser using DataLab