Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jtleek committed May 5, 2014
1 parent 05144bc commit 1199ce3
Show file tree
Hide file tree
Showing 4 changed files with 2,269 additions and 152 deletions.
62 changes: 51 additions & 11 deletions 09_DevelopingDataProducts/googleVis/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ mode : selfcontained # {standalone, draft}

https://developers.google.com/chart/interactive/docs/gallery

```{r, setOptions, echo=FALSE}
options(gvis.plot.tag="chart")
```

---

Expand All @@ -38,8 +35,9 @@ options(gvis.plot.tag="chart")

```{r gv,results="asis"}
suppressPackageStartupMessages(library(googleVis))
plot(gvisMotionChart(Fruits, "Fruit", "Year",
options=list(width=600, height=400)))
M <- gvisMotionChart(Fruits, "Fruit", "Year",
options=list(width=600, height=400))
print(M,"chart")
```

---
Expand All @@ -62,7 +60,9 @@ http:https://cran.r-project.org/web/packages/googleVis/googleVis.pdf
## Plots on maps

```{r,dependson="gv",results="asis"}
plot(gvisGeoChart(Exports, locationvar="Country",colorvar="Profit",options=list(width=600, height=400)))
G <- gvisGeoChart(Exports, locationvar="Country",
colorvar="Profit",options=list(width=600, height=400))
print(G,"chart")
```


Expand All @@ -71,7 +71,9 @@ plot(gvisGeoChart(Exports, locationvar="Country",colorvar="Profit",options=list(
## Specifying a region

```{r,dependson="gv",results="asis"}
plot(gvisGeoChart(Exports, locationvar="Country",colorvar="Profit",options=list(width=600, height=400,region="150")))
G2 <- gvisGeoChart(Exports, locationvar="Country",
colorvar="Profit",options=list(width=600, height=400,region="150"))
print(G2,"chart")
```

---
Expand All @@ -83,24 +85,63 @@ plot(gvisGeoChart(Exports, locationvar="Country",colorvar="Profit",options=list(

https://developers.google.com/chart/interactive/docs/gallery/geochart

---

## Setting more options

```{r linechart,dependson="gv",results="asis"}
df <- data.frame(label=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))
Line <- gvisLineChart(df, xvar="label", yvar=c("val1","val2"),
options=list(title="Hello World", legend="bottom",
titleTextStyle="{color:'red', fontSize:18}",
vAxis="{gridlines:{color:'red', count:3}}",
hAxis="{title:'My Label', titleTextStyle:{color:'blue'}}",
series="[{color:'green', targetAxisIndex: 0},
{color: 'blue',targetAxisIndex:1}]",
vAxes="[{title:'Value 1 (%)', format:'##,######%'},
{title:'Value 2 (\U00A3)'}]",
curveType="function", width=500, height=300
))
```

https://github.com/mages/Introduction_to_googleVis/blob/gh-pages/index.Rmd

---

## Setting more options

```{r ,dependson="linechart",results="asis"}
print(Line,"chart")
```



---

## Combining multiple plots together

```{r,dependson="gv",results="asis"}
```{r multiplot,dependson="gv",results="asis"}
G <- gvisGeoChart(Exports, "Country", "Profit",options=list(width=200, height=100))
T1 <- gvisTable(Exports,options=list(width=200, height=270))
M <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(width=400, height=370))
GT <- gvisMerge(G,T1, horizontal=FALSE)
GTM <- gvisMerge(GT, M, horizontal=TRUE,tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")
plot(GTM)
```

---

## Combining multiple plots together

```{r,dependson="multiplot",results="asis"}
print(GTM,"chart")
```


---

## Seeing the HTML code

```{r ,dependson="gv",results="asis"}
```{r ,dependson="gv"}
M <- gvisMotionChart(Fruits, "Fruit", "Year", options=list(width=600, height=400))
print(M)
print(M, 'chart', file='myfilename.html')
Expand All @@ -115,7 +156,6 @@ print(M, 'chart', file='myfilename.html')
* Embed them in [R markdown](http:https://www.rstudio.com/ide/docs/authoring/using_markdown) based documents
* Set `results="asis"` in the chunk options
* Can be used with [knitr](http:https://cran.r-project.org/web/packages/knitr/index.html) and [slidify](http:https://slidify.org/)
*


---
Expand Down
Loading

0 comments on commit 1199ce3

Please sign in to comment.