This function creates a Highchart chart using htmlwidgets. The widget can be rendered on HTML pages generated from R Markdown, Shiny, or other applications.
Arguments
- hc_opts
A
listobject containing options defined as https://api.highcharts.com/highcharts/.- theme
A preset name or an object created with
hc_theme().- type
A character value to set if use Highchart, Highstock or Highmap. Options are
"chart","stock"and"map".- width
A numeric width in pixels, or a CSS width such as
"100%".- height
A numeric input in pixels.
- elementId
Use an explicit element ID for the widget.
Examples
tokyo <- subset(city_weather, city == "Tokyo")
highchart(width = "100%") |>
hc_add_series(tokyo, "line", hcaes(date, temp_mean), name = "Tokyo") |>
hc_xAxis(type = "datetime") |>
hc_title(text = "Daily mean temperature in Tokyo, 2025")
# Stock navigation is available in the shared bundle.
prices <- data.frame(
day = base::as.Date("2025-01-01") + 0:9,
close = c(100, 102, 101, 104, 103, 106, 108, 107, 109, 112)
)
highchart(type = "stock", width = "100%") |>
hc_add_series(prices, "line", hcaes(x = day, y = close), name = "Close")
