The objective of this vignette is to show how to quickly build data visualizations with the ApexCharts JavaScript library, as well as to give an overview of the different graphics available.
Data used are from `ggplot2` package, data manipulation will be done with the `dplyr` package.
```{r}
library(ggplot2)
library(dplyr)
library(apexcharter)
```
## Bar charts
Simple bar charts can be created with:
```{r}
data("mpg")
n_manufac <- count(mpg, manufacturer)
apex(data = n_manufac, type = "column", mapping = aes(x = manufacturer, y = n))
```
Flipping coordinates can be done by using `type = "bar"`:
```{r}
apex(data = n_manufac, type = "bar", mapping = aes(x = manufacturer, y = n))
```
To create a dodge bar charts, use aesthetic `fill` :
```{r}
n_manufac_year <- count(mpg, manufacturer, year)
apex(data = n_manufac_year, type = "column", mapping = aes(x = manufacturer, y = n, fill = year))
```
For stacked bar charts, specify option `stacked` in `ax_chart` :
```{r}
apex(data = n_manufac_year, type = "column", mapping = aes(x = manufacturer, y = n, fill = year)) %>%
ax_chart(stacked = TRUE)
```
## Line charts
Simple line charts can be created with (works with `character`, `Date` or `POSIXct`):