---
title: "Labs: title, subtitle & axis"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{labs}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```


Packages and data used below:

```{r message=FALSE, warning=FALSE}
library(apexcharter)
library(dplyr)

data("diamonds", package = "ggplot2")
n_cut <- dplyr::count(diamonds, cut)
```


## Chart title

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_title(text = "Cut distribution")
```

You can set some options, for example:

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_title(
    text = "Cut distribution", 
    align = "center",
    style = list(fontSize = "22px")
  )
```


Full list of parameters is available here : https://apexcharts.com/docs/options/title/


## Chart subtitle

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_title(text = "Cut distribution") %>% 
  ax_subtitle(text = "Data from ggplot2")
```

With same options than for title:

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_title(
    text = "Cut distribution", 
    align = "center",
    style = list(fontSize = "22px")
  ) %>% 
  ax_subtitle(
    text = "Data from ggplot2", 
    align = "center",
    style = list(fontSize = "16px", color = "#BDBDBD")
  )
```

Full list of parameters is available here : https://apexcharts.com/docs/options/subtitle/


## Axis title

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_yaxis(title = list(text = "Count")) %>% 
  ax_xaxis(title = list(text = "Cut"))
```

With some options:

```{r}
apex(data = n_cut, type = "column", mapping = aes(x = cut, y = n)) %>% 
  ax_yaxis(title = list(
    text = "Count",
    style = list(fontSize = "14px", color = "#BDBDBD")
  )) %>% 
  ax_xaxis(title = list(
    text = "Cut", 
    style = list(fontSize = "14px", color = "#BDBDBD")
  ))
```




