<!--
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Using Roles and Intervals via googleVis}
-->
# Using Roles via googleVis

Roles add the ability to pass columns for further processing downstream. 
Role columns must follow column they pertain to. Proper naming
conventions must be observed. For example, roles fulfilling tooltip
roles and must be called "foo.blah.tooltip". For more details see the [Google documentation](https://developers.google.com/chart/interactive/docs/roles).

The following examples should help to illustrate the concept. 

```{r setOptions, message=FALSE, echo=FALSE}
library(googleVis)
library(knitr)
op <- options(gvis.plot.tag='chart')
read_demo('Roles', 'googleVis')
```
The first example uses a data set that has the additional column
`pop.html.tooltip` with the first 11 letters of the Latin alphabet.
This column is mapped automatically as a tooltip when the user hovers 
over the chart point.
```{r Tooltip, results='asis', tidy=FALSE}
```
HTML code can be embedded into the tooltip as well, if the option 
isHtml is set to true.
```{r TooltipHTML, results='asis', tidy=FALSE}
```
Often it is helpful to highlight certain parts of the data. The Google API
distinguishes between certainty and emphasis.
In a similar way to above additional columns with boolean values
have to be added to the data.
```{r CertaintyScopeEmphasis, results='asis', tidy=FALSE}
```

Using roles with column or bar charts has some specifics.
Instead of 'emphasize' use 'style' to change the colours.
```{r ColumnChart, results='asis', tidy=FALSE}
```


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

Setting the annotations style to 'line' allows adding little reference lines
to the plot.
```{r VerticalReferenceLine, results='asis', tidy=FALSE}
```

Intervals help to add error bars, confidence levels, etc.
Note that the options are set either via `interval` or `intervals`, 
if set to all intervals. The examples below give an indication of what 
can be achieved with intervals. 
For more details visit the Google [documentation](https://google-developers.appspot.com/chart/interactive/docs/gallery/intervals).

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