hgch_line | R Documentation |
Creates a line chart using Highcharter library.
hgch_line(
data,
dic = NULL,
var_cat = NULL,
var_dat = NULL,
var_num = NULL,
...
)
data |
a data frame containing the variables to be plotted. |
dic |
a named list, each element corresponding to a column name in |
var_cat |
the name of the categorical variable in the data frame |
var_dat |
a character vector with the names of date variable. |
var_num |
a character vector with the names of numerical variables. |
... |
additional arguments to be passed to |
a Highcharter line chart.
data_draw
dates <- seq(as.POSIXct("2022-01-01"),
as.POSIXct("2022-01-10"),
by = "day")
values <- rnorm(length(dates))
df <- data.frame(date = dates, value = values)
hgch_line(df, var_dat = "date", var_num = "value")
### Custom colors
data <- lubridate::lakers
data$date <- lubridate::ymd(data$date)
data <- data |>
dplyr::group_by(game_type, date) |>
dplyr::summarise(x = sum(x, na.rm = T))
hgch_line(data,
var_cat = "game_type",
var_dat = "date",
var_num = "x",
palette_colors = c("#ffa92a", "#f06142"),
hor_title = "fecha",
ver_title = "valor")
# Custom theme
test_theme <- list(
theme = list(
palette_colors = c("#ffa92a", "lightgreen"),
subtitle_align = "center",
subtitle_family = "Roboto",
subtitle_size = 15,
subtitle_color = "#3b83b8",
subtitle_weight = 700
)
)
# plot
hgch_line(data,
var_cat = "game_type",
var_dat = "date",
var_num = "x",
hor_title = "fecha",
ver_title = "valor",
opts = test_theme)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.