hgch_line: Highcharter line Chart

hgch_lineR Documentation

Highcharter line Chart

Description

Creates a line chart using Highcharter library.

Usage

hgch_line(
  data,
  dic = NULL,
  var_cat = NULL,
  var_dat = NULL,
  var_num = NULL,
  ...
)

Arguments

data

a data frame containing the variables to be plotted.

dic

a named list, each element corresponding to a column name in data and defining a set of labels for that column.

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 dsviz_default_opts

Value

a Highcharter line chart.

See Also

data_draw

Examples

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)


randommonkey/hgchmagic documentation built on Aug. 23, 2023, 5:56 a.m.