library("googleVis") ## Add edit button for on the fly customisation ## The same option is available for all other charts Line4 <- gvisLineChart(df, "country", c("val1","val2"),options=list(gvis.editor="Edit me!")) ## Scatter chart Scatter <- gvisScatterChart(women, options=list(legend="none",lineWidth=2, pointSize=0,title="Women", vAxis="{title:'weight (lbs)'}",hAxis="{title:'height (in)'}", width=300, height=300)) plot(Scatter) ## Bubble chart Bubble <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",colorvar="Year", sizevar="Profit",options=list(hAxis='{minValue:75, maxValue:125}')) plot(Bubble) ## Pie chart Pie <- gvisPieChart(CityPopularity) plot(Pie) ## Gauge Gauge <- gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,greenTo=800, yellowFrom=300, yellowTo=500,redFrom=0, redTo=300, width=400, height=300)) plot(Gauge) ## Org chart Org <- gvisOrgChart(Regions, options=list(width=600, height=250,size='large', allowCollapse=TRUE)) plot(Org) ## Motion chart, requires Flash Motion=gvisMotionChart(Fruits, idvar="Fruit", timevar="Year") plot(Motion) ## You can change some of displaying settings via the browser, ## e.g. the level of opacity of non-selected items, or the chart type. ## The state string from the 'Advanced' tab can be used to set those ## settings via R. Just copy and past the string from the browser into ## the argument state of the options list. ## Here is an example of a motion chart, with an initial line chart ## displayed. myStateSettings <-{"xZoomedDataMin":1199145600000,"colorOption":"2","duration":{"timeUnit":"Y","multiplier":1},"yLambda":1,"yAxisOption":"4","sizeOption":"_UNISIZE","iconKeySettings":[],"xLambda":1,"nonSelectedAlpha":0,"xZoomedDataMax":1262304000000,"iconType":"LINE","dimensions":{"iconDimensions":["dim0"]},"showTrails":false,"uniColorForNonSelected":false,"xAxisOption":"_TIME","orderedByX":false,"playDuration":15000,"xZoomedIn":false,"time":"2010","yZoomedDataMin":0,"yZoomedIn":false,"orderedByY":false,"yZoomedDataMax":100} M <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(state=myStateSettings)) plot(M) ## Intensity Map Intensity <- gvisIntensityMap(df) plot(Intensity) ## Example showing US data by state require(datasets) states <- data.frame(state.name, state.x77) GeoStates <- gvisGeoChart(states, "state.name", "Illiteracy",options=list(region="US", displayMode="regions", resolution="provinces",width=600, height=400)) plot(GeoStates) ## US Flu Chart require(datasets) setwd("C:/Users/.../Desktop") FluStateData<-read.csv("FluStateData.csv",sep=",",header=TRUE) FluData<-FluStateData[(!(duplicated(FluStateData[,1],fromLast=TRUE))),] GeoStates <- gvisGeoChart(FluData, "STATENAME", "ACTIVITY.LEVEL",options=list(region="US", displayMode="regions", resolution="provinces",width=600, height=400)) plot(GeoStates) ## Show Hurricane Andrew (1992) storm track with Geo Chart GeoMarker <- gvisGeoChart(Andrew, "LatLong", sizevar='Speed_kt',colorvar="Pressure_mb", options=list(region="US")) plot(GeoMarker) ## Geo Map, requires Flash Geo=gvisGeoMap(Exports, locationvar="Country", numvar="Profit",options=list(height=350, dataMode='regions')) plot(Geo) ## Show Hurricane Andrew (1992) storm track with Geo Map AndrewGeo <- gvisGeoMap(Andrew, locationvar="LatLong", numvar="Speed_kt", hovervar="Category",options=list(height=350, region="US", dataMode="markers")) plot(AndrewGeo) ## Hurricane Andrew (1992) storm track with Google Maps AndrewMap <- gvisMap(Andrew, "LatLong" , "Tip",options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE,mapType='terrain', useMapTypeControl=TRUE)) plot(AndrewMap) ## Table with embedded links PopTable <- gvisTable(Population, options=list(width=600, height=300, page='enable')) plot(PopTable) ## Annotated time line chart, requires Flash AnnoTimeLine <- gvisAnnotatedTimeLine(Stock, datevar="Date",numvar="Value", idvar="Device",titlevar="Title", annotationvar="Annotation",options=list(displayAnnotations=TRUE,width=600, height=350)) plot(AnnoTimeLine) G <- gvisGeoChart(Exports, "Country", "Profit", options=list(width=210, height=100)) TT <- gvisTable(Exports, options=list(width=210, height=270)) GT <- gvisMerge(G,TT, horizontal=FALSE) M <- gvisMotionChart(Fruits, "Fruit", "Year",options=list(width=410, height=370)) GTM <- gvisMerge(GT, M, horizontal=TRUE,tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10") plot(GTM)