---
title: "googleVis examples"
author: "Markus Gesmann and Diego de Castillo"
date: "`r Sys.Date()`"
output:
  html_document:
    toc: true
    toc_depth: 2
    toc_float:
      collapsed: false
      smooth_scroll: false
    number_sections: true
    self_contained: false
---

<!--
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Demonstration of googleVis}
-->


```{js, echo=FALSE}
$('.title').css('color', 'darkred')
```

# Demonstration of googleVis

It may take a little while to load all charts. Please be patient.
All charts require an Internet connection.

These examples are taken from the googleVis demo. 
You can execute the demo via
```{r demo, eval=FALSE}
library(googleVis)
demo(googleVis)
```

For more details about the charts and further examples see the 
help files of the individual googleVis function and review the 
[Google Charts API documentation](https://developers.google.com/chart/interactive/docs/gallery) and [Terms of Service](https://developers.google.com/chart/terms).

## Line chart
```{r setOptions, message=FALSE, echo=FALSE}
library(googleVis)
library(knitr)
op <- options(gvis.plot.tag='chart')
read_demo('googleVis', 'googleVis')
```
```{r testData, tidy=FALSE}
```
```{r LineChart, results='asis', tidy=FALSE}
```

### Line chart with two axis
```{r TwoAxis, results='asis', tidy=FALSE}
```

## Bar chart
```{r BarChart, results='asis', tidy=FALSE}
```

## Column chart
```{r ColumnChart, results='asis', tidy=FALSE}
```

## Area chart
```{r AreaChart, results='asis', tidy=FALSE}
```

## Stepped Area chart
```{r SteppedAreaChart, results='asis', tidy=FALSE}
```

## Combo chart
```{r ComboChart, results='asis', tidy=FALSE}
```

## Scatter chart
```{r ScatterChart, results='asis', tidy=FALSE}
```

## Bubble chart
```{r BubbleChart, results='asis', tidy=FALSE}
```

### Customizing Lines
```{r CustomizingLines, results='asis', tidy=FALSE}
```


## Customizing points
```{r ScatterChartPoints, results='asis', tidy=FALSE}
```

### Add edit button for on the fly customisation
```{r EditButton, results='asis', tidy=FALSE}
```
The same option is available for all other charts as well.

### A chart with many options set
```{r SettingOptions, results='asis', tidy=FALSE}
```

## Candlestick chart
```{r CandlestickChart, results='asis', tidy=FALSE}
```

## Pie chart
```{r PieChart, results='asis', tidy=FALSE}
```

## Gauge
```{r Gauge, results='asis', tidy=FALSE}
```


## Geo Chart
```{r GeoChart, results='asis', tidy=FALSE}
```

### Example showing US data by state
```{r USStateData, results='asis', tidy=FALSE}
```

### Show Hurricane Andrew (1992) storm track with markers
```{r GeoChartHurricaneAndrew, results='asis', tidy=FALSE}
```

## Table
```{r Table, results='asis', tidy=FALSE}
```
Click on the column header to sort the rows

### Table with pages
```{r TableWithPages, results='asis', tidy=FALSE}
```

## Org chart
```{r OrgChart, results='asis', tidy=FALSE}
```
Double click on a parent to collapse all its children.

## Tree Map
```{r TreeMap, results='asis', tidy=FALSE}
```
Left mouse-click to drill down, right mouse-click to move up a level.

## Annotation chart
```{r AnnotationChart, results='asis', tidy=FALSE}
```

## Sankey chart
```{r SankeyChart, results='asis', tidy=FALSE}
```

## Histogram
```{r Histogram, results='asis', tidy=FALSE}
```

## Calendar chart
```{r CalendarChart, results='asis', tidy=FALSE}
```

## Timeline chart
```{r Timeline, results='asis', tidy=FALSE}
```

## Word tree chart
```{r WordTree, results='asis', tidy=FALSE}
```

## Merging charts
```{r gvisMerge, results='asis', tidy=FALSE}
```

# Flash charts
All the following chart requires a Flash player.


## Motion chart

The Google motion chart requires Flash, which is no longer
supported by most browsers. An alternative is `plotly::ggplotly`. For more see [https://plotly.com/r/animations/#mulitple-trace-animations](https://plotly.com/r/animations/#mulitple-trace-animations)

```{r MotionChart, results='asis', tidy=FALSE}
```

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.

```{r MotionChartSettings, results='asis', tidy=FALSE}
```
