diff --git a/R/highcharts-api.R b/R/highcharts-api.R index f3f13dfb..95dd0a45 100644 --- a/R/highcharts-api.R +++ b/R/highcharts-api.R @@ -1,59 +1,59 @@ # Generated by 'dev/generate-highcharts-api.R' -# Generated in 2021-02-02 12:43:12 +# Generated in 2022-08-07 20:58:21 # #' Annotations options for highcharter objects -#' +#' #' A basic type of an annotation. It allows to add custom labels #' or shapes. The items can be tied to points, axis coordinates #' or chart pixel coordinates. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/annotations}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/annotations}. +#' #' @examples -#' +#' #' # Ex 1 -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) -#' ) %>% +#' ) |> #' hc_xAxis( #' tickInterval = 0.5, -#' gridLineWidth = 1 -#' ) %>% +#' gridLineWidth = 1 +#' ) |> #' hc_annotations( #' list( -#' labels = +#' labels = #' list( #' list( #' point = list(x = 3, y = 129.2, xAxis = 0, yAxis = 0), #' text = "x: {x}
y: {y}" -#' ), +#' ), #' list( #' point = list(x = 9, y = 194.1, xAxis = 0, yAxis = 0), #' text = "x: {x}
y: {y}" -#' ), +#' ), #' list( #' point = list(x = 5, y = 100, xAxis = 0), #' text = "x: {x}
y: {point.plotY} px" -#' ), +#' ), #' list( #' point = list(x = 0, y = 0), #' text = "x: {point.plotX} px
y: {point.plotY} px" +#' ) #' ) -#' ) +#' ) #' ) -#' ) -#' +#' #' # Ex 2 #' df <- data.frame( #' x = 1:10, #' y = 1:10 #' ) -#' -#' highchart() %>% -#' hc_add_series(data = df, hcaes(x = x, y = y), type = "area") %>% +#' +#' highchart() |> +#' hc_add_series(data = df, hcaes(x = x, y = y), type = "area") |> #' hc_annotations( #' list( #' labels = list( @@ -62,13 +62,16 @@ #' ) #' ) #' ) +#' #' @export hc_annotations <- function(hc, ...) { + .hc_opt(hc, "annotations", ...) + } #' Boost options for highcharter objects -#' +#' #' Options for the Boost module. The Boost module allows certain series types #' to be rendered by WebGL instead of the default SVG. This allows hundreds of #' thousands of data points to be rendered in milliseconds. In addition to the @@ -80,84 +83,84 @@ hc_annotations <- function(hc, ...) { #' boostThreshold that defines when the #' boost should kick in. #' Requires the modules/boost.js module. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/boost}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/boost}. +#' #' @examples -#' +#' #' # Ex 1 #' options(highcharter.rjson = FALSE) -#' +#' #' n <- 50000 -#' -#' x <- sin(4 * 2 * pi * seq(n) / n) + rnorm(n) / 10 -#' +#' +#' x <- sin(4*2*pi*seq(n)/n) + rnorm(n)/10 +#' #' x <- round(x, 3) -#' +#' #' plot(x) -#' -#' hc1 <- highchart() %>% -#' hc_chart(zoomType = "x") %>% -#' hc_add_series(data = x) %>% -#' hc_title(text = "No boost") %>% +#' +#' hc1 <- highchart() |> +#' hc_chart(zoomType = "x") |> +#' hc_add_series(data = x) |> +#' hc_title(text = "No boost") |> #' hc_boost( #' enabled = FALSE # Default #' ) -#' +#' #' hc1 -#' +#' #' # Boost is a stripped-down renderer-in-a-module for Highcharts. It bypasses #' # some of the standard Highcharts features (such as animation), and focuses #' # on pushing as many points as possible as quickly as possible. -#' -#' hc2 <- highchart() %>% -#' hc_chart(zoomType = "x") %>% -#' hc_add_series(data = x) %>% -#' hc_title(text = "With boost") %>% +#' +#' hc2 <- highchart() |> +#' hc_chart(zoomType = "x") |> +#' hc_add_series(data = x) |> +#' hc_title(text = "With boost") |> #' hc_boost(enabled = TRUE) -#' +#' #' hc2 -#' -#' +#' +#' #' # # Ex 2 #' # library(MASS) -#' # +#' # #' # n <- 20000 -#' # +#' # #' # sigma <- matrix(c(10,3,3,2),2,2) #' # sigma -#' # +#' # #' # mvr <- round(mvrnorm(n, rep(c(0, 0)), sigma), 2) -#' # +#' # #' # vx <- ceiling(1+abs(max(mvr[, 1]))) #' # vy <- ceiling(1+abs(max(mvr[, 2]))) -#' # +#' # #' # # unnamed list #' # ds <- list_parse2(as.data.frame(mvr)) -#' # -#' # highchart() %>% -#' # hc_chart(zoomType = "xy") %>% -#' # hc_xAxis(min = -vx, max = vx) %>% -#' # hc_yAxis(min = -vy, max = vy) %>% +#' # +#' # highchart() |> +#' # hc_chart(zoomType = "xy") |> +#' # hc_xAxis(min = -vx, max = vx) |> +#' # hc_yAxis(min = -vy, max = vy) |> #' # hc_add_series( #' # data = ds, #list #' # type = "scatter", #' # name = "A lot of points!", #' # color = 'rgba(0,0,0,0.1)', #' # marker = list(radius = 2) -#' # ) %>% +#' # ) |> #' # hc_boost( -#' # enabled = TRUE +#' # enabled = TRUE #' # ) -#' # +#' # #' # dat <- as.data.frame(mvr) #' # names(dat) <- c("x", "y") -#' # -#' # highchart() %>% -#' # hc_chart(zoomType = "xy") %>% -#' # hc_xAxis(min = -vx, max = vx) %>% -#' # hc_yAxis(min = -vy, max = vy) %>% +#' # +#' # highchart() |> +#' # hc_chart(zoomType = "xy") |> +#' # hc_xAxis(min = -vx, max = vx) |> +#' # hc_yAxis(min = -vy, max = vy) |> #' # hc_add_series( #' # data = dat, #' # type = "scatter", @@ -165,90 +168,96 @@ hc_annotations <- function(hc, ...) { #' # name = "A lot of points!", #' # color = 'rgba(0,0,0,0.1)', #' # marker = list(radius = 2) -#' # ) %>% +#' # ) |> #' # hc_boost(enabled = TRUE) -#' # +#' # #' # # Ex3 #' # N <- 1000000 #' # n <- 5 #' # s <- seq(n) #' # s <- s/(max(s) + min(s)) #' # s <- round(s, 2) -#' # -#' # series <- s %>% -#' # purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) %>% -#' # purrr::map(as.vector) %>% -#' # purrr::map(round, 2) %>% +#' # +#' # series <- s |> +#' # purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) |> +#' # purrr::map(as.vector) |> +#' # purrr::map(round, 2) |> #' # purrr::map(~ list(data = .x)) -#' # -#' # highchart() %>% -#' # hc_add_series_list(series) %>% -#' # hc_chart(zoomType = "x") %>% +#' # +#' # highchart() |> +#' # hc_add_series_list(series) |> +#' # hc_chart(zoomType = "x") |> #' # hc_boost(enabled = TRUE) +#' #' @export hc_boost <- function(hc, ...) { + .hc_opt(hc, "boost", ...) + } #' Caption options for highcharter objects -#' +#' #' The chart's caption, which will render below the chart and will be part #' of exported charts. The caption can be updated after chart initialization #' through the Chart.update or Chart.caption.update methods. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/caption}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/caption}. +#' #' @examples -#' -#' highchart() %>% -#' hc_title(text = "Chart with a caption") %>% -#' hc_subtitle(text = "This is the subtitle") %>% -#' hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) %>% +#' +#' highchart() |> +#' hc_title(text= "Chart with a caption") |> +#' hc_subtitle(text= "This is the subtitle") |> +#' hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) |> #' hc_add_series( #' data = c(1, 4, 3, 5), #' type = "column", #' name = "Fruits" -#' ) %>% +#' ) |> #' hc_caption( #' text = "The caption renders in the bottom, and is part of the exported #' chart.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, #' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim -#' ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip -#' ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate -#' velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat +#' ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip +#' ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate +#' velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat #' cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est #' laborum.'" #' ) +#' #' @export hc_caption <- function(hc, ...) { + .hc_opt(hc, "caption", ...) + } #' Chart options for highcharter objects -#' +#' #' General options for the chart. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/chart}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/chart}. +#' #' @examples -#' -#' hc <- highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' +#' hc <- highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_add_series(name = "London", data = sample(1:12) + 10) -#' +#' #' hc -#' -#' hc %>% +#' +#' hc |> #' hc_chart( #' type = "column", #' options3d = list(enabled = TRUE, beta = 15, alpha = 15) -#' ) -#' -#' -#' hc %>% +#' ) +#' +#' +#' hc |> #' hc_chart( #' borderColor = "#EBBA95", #' borderRadius = 10, @@ -256,18 +265,22 @@ hc_caption <- function(hc, ...) { #' backgroundColor = list( #' linearGradient = c(0, 0, 500, 500), #' stops = list( -#' list(0, "rgb(255, 255, 255)"), -#' list(1, "rgb(200, 200, 255)") +#' list(0, 'rgb(255, 255, 255)'), +#' list(1, 'rgb(200, 200, 255)') +#' ) #' ) #' ) -#' ) +#' +#' #' @export hc_chart <- function(hc, ...) { + .hc_opt(hc, "chart", ...) + } #' Coloraxis options for highcharter objects -#' +#' #' A color axis for series. Visually, the color #' axis will appear as a gradient or as separate items inside the #' legend, depending on whether the axis is scalar or based on data @@ -294,159 +307,166 @@ hc_chart <- function(hc, ...) { #' Since v7.2.0 colorAxis can also be an array of options objects. #' See the Axis object for #' programmatic access to the axis. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/colorAxis}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/colorAxis}. +#' #' @examples -#' +#' #' library(dplyr) -#' +#' #' data(mpg, package = "ggplot2") -#' -#' mpgman2 <- mpg %>% -#' group_by(manufacturer, year) %>% +#' +#' mpgman2 <- mpg |> +#' group_by(manufacturer, year) |> #' dplyr::summarise( #' n = dplyr::n(), -#' displ = mean(displ) -#' ) -#' +#' displ = mean(displ), +#' .groups = "drop" +#' ) +#' #' mpgman2 -#' +#' #' hchart( #' mpgman2, "column", hcaes(x = manufacturer, y = n, group = year), #' colorKey = "displ", #' # color = c("#FCA50A", "#FCFFA4"), #' name = c("Year 1999", "Year 2008") -#' ) %>% +#' ) |> #' hc_colorAxis(min = 0, max = 5) -#' -#' +#' +#' #' # defaults to yAxis -#' hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) %>% +#' hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) |> #' hc_colorAxis( #' minColor = "red", #' maxColor = "blue" #' ) -#' -#' -#' +#' #' # Ex2 #' n <- 5 -#' +#' #' stops <- data.frame( -#' q = 0:n / n, +#' q = 0:n/n, #' c = c("#440154", "#414487", "#2A788E", "#22A884", "#7AD151", "#FDE725"), #' stringsAsFactors = FALSE -#' ) -#' +#' ) +#' #' stops <- list_parse2(stops) -#' -#' M <- round(matrix(rnorm(50 * 50), ncol = 50), 2) -#' -#' hchart(M) %>% +#' +#' M <- round(matrix(rnorm(50*50), ncol = 50), 2) +#' +#' hchart(M) |> #' hc_colorAxis(stops = stops) -#' +#' #' # Ex3 -#' # hchart(volcano) %>% -#' # hc_colorAxis(stops = stops, max = 200) +#' hchart(volcano) |> +#' hc_colorAxis(stops = stops, max = 200) +#' #' @export hc_colorAxis <- function(hc, ...) { + .hc_opt(hc, "colorAxis", ...) + } #' Colors options for highcharter objects -#' -#' An array containing the default colors for the chart's series. When all +#' +#' An array containing the default colors for the chart's series. When all #' colors are used, new colors are pulled from the start again. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param colors A vector of colors. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param colors A vector of colors. +#' #' @examples -#' +#' #' library(viridisLite) -#' +#' #' cols <- viridis(3) #' cols <- substr(cols, 0, 7) -#' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% -#' hc_add_series(data = sample(1:12) + 10) %>% -#' hc_add_series(data = sample(1:12) + 20) %>% +#' +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> +#' hc_add_series(data = sample(1:12) + 10) |> +#' hc_add_series(data = sample(1:12) + 20) |> #' hc_colors(cols) +#' #' @export hc_colors <- function(hc, colors) { + assertthat::assert_that(is.vector(colors)) - - if (length(colors) == 1) { + + if (length(colors) == 1) colors <- list(colors) - } hc$x$hc_opts$colors <- colors - + hc + } #' Credits options for highcharter objects -#' +#' #' Highchart by default puts a credits label in the lower right corner #' of the chart. This can be changed using these options. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/credits}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/credits}. +#' #' @examples -#' -#' highchart() %>% -#' hc_xAxis(categories = citytemp$month) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' +#' highchart() |> +#' hc_xAxis(categories = citytemp$month) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_credits( #' enabled = TRUE, #' text = "htmlwidgets.org", #' href = "http://www.htmlwidgets.org/" -#' ) +#' ) +#' #' @export hc_credits <- function(hc, ...) { + .hc_opt(hc, "credits", ...) + } #' Drilldown options for highcharter objects -#' +#' #' Options for drill down, the concept of inspecting increasingly high #' resolution data through clicking on chart items like columns or pie slices. #' The drilldown feature requires the drilldown.js file to be loaded, #' found in the modules directory of the download package, or online at #' code.highcharts.com/modules/drilldown.js. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/drilldown}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/drilldown}. +#' #' @examples -#' +#' #' library(highcharter) #' library(dplyr) #' library(purrr) -#' +#' #' df <- tibble( #' name = c("Animals", "Fruits"), #' y = c(5, 2), #' drilldown = tolower(name) #' ) -#' +#' #' df -#' -#' hc <- highchart() %>% -#' hc_title(text = "Basic drilldown") %>% -#' hc_xAxis(type = "category") %>% -#' hc_legend(enabled = FALSE) %>% +#' +#' hc <- highchart() |> +#' hc_title(text = "Basic drilldown") |> +#' hc_xAxis(type = "category") |> +#' hc_legend(enabled = FALSE) |> #' hc_plotOptions( #' series = list( #' boderWidth = 0, #' dataLabels = list(enabled = TRUE) #' ) -#' ) %>% +#' ) |> #' hc_add_series( #' data = df, #' type = "column", @@ -454,23 +474,23 @@ hc_credits <- function(hc, ...) { #' name = "Things", #' colorByPoint = TRUE #' ) -#' +#' #' dfan <- data.frame( #' name = c("Cats", "Dogs", "Cows", "Sheep", "Pigs"), #' value = c(4, 3, 1, 2, 1) #' ) -#' +#' #' dffru <- data.frame( #' name = c("Apple", "Organes"), #' value = c(4, 2) #' ) -#' -#' +#' +#' #' dsan <- list_parse2(dfan) -#' +#' #' dsfru <- list_parse2(dffru) -#' -#' hc <- hc %>% +#' +#' hc <- hc |> #' hc_drilldown( #' allowPointDrilldown = TRUE, #' series = list( @@ -484,52 +504,60 @@ hc_credits <- function(hc, ...) { #' ) #' ) #' ) -#' +#' #' hc +#' +#' +#' #' @export hc_drilldown <- function(hc, ...) { + .hc_opt(hc, "drilldown", ...) + } #' Exporting options for highcharter objects -#' +#' #' Options for the exporting module. For an overview on the matter, see #' the docs. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/exporting}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/exporting}. +#' #' @examples -#' -#' highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' +#' highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_exporting( #' enabled = TRUE, # always enabled #' filename = "custom-file-name" -#' ) +#' ) +#' #' @export hc_exporting <- function(hc, ...) { + .hc_opt(hc, "exporting", ...) + } #' Labels options for highcharter objects -#' +#' #' HTML labels that can be positioned anywhere in the chart area. #' This option is deprecated since v7.1.2. Instead, use #' annotations that support labels. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/labels}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/labels}. +#' #' @examples -#' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% +#' +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> #' hc_labels( #' items = list( #' list( -#' html = "

Some important
text

", +#' html = "

Some important
text

" , #' style = list( #' left = "150%", #' top = "150%" @@ -537,47 +565,54 @@ hc_exporting <- function(hc, ...) { #' ) #' ) #' ) +#' +#' #' @export hc_labels <- function(hc, ...) { + .hc_opt(hc, "labels", ...) + } #' Legend options for highcharter objects -#' +#' #' The legend is a box containing a symbol and name for each series #' item or point item in the chart. Each series (or points in case #' of pie charts) is represented by a symbol and its name in the legend. #' It is possible to override the symbol creator function and create #' custom legend symbols. -#' +#' #' A Highmaps legend by default contains one legend item per series, but if #' a colorAxis is defined, the axis will be displayed in the legend. #' Either as a gradient, or as multiple legend items for dataClasses. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/legend}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/legend}. +#' #' @examples -#' -#' highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% -#' hc_add_series(name = "London", data = sample(1:12) + 10) %>% -#' hc_add_series(name = "Other City", data = sample(1:12) + 20) %>% +#' +#' highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> +#' hc_add_series(name = "London", data = sample(1:12) + 10) |> +#' hc_add_series(name = "Other City", data = sample(1:12) + 20) |> #' hc_legend( #' align = "left", #' verticalAlign = "top", #' layout = "vertical", #' x = 0, #' y = 100 -#' ) +#' ) +#' #' @export hc_legend <- function(hc, ...) { + .hc_opt(hc, "legend", ...) + } #' Loading options for highcharter objects -#' +#' #' The loading options control the appearance of the loading screen #' that covers the plot area on chart operations. This screen only #' appears after an explicit call to chart.showLoading(). It is a @@ -585,49 +620,52 @@ hc_legend <- function(hc, ...) { #' is going on, for example while retrieving new data via an XHR connection. #' The "Loading..." text itself is not part of this configuration #' object, but part of the lang object. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/loading}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/loading}. +#' #' @examples -#' -#' highcharts_demo() %>% +#' +#' highcharts_demo() |> #' hc_loading( #' hideDuration = 1000, #' showDuration = 1000 #' ) +#' #' @export hc_loading <- function(hc, ...) { + .hc_opt(hc, "loading", ...) + } #' Pane options for highcharter objects -#' +#' #' The pane serves as a container for axes and backgrounds for circular #' gauges and polar charts. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/pane}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/pane}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_chart( -#' type = "gauge", -#' plotBackgroundColor = NULL, -#' plotBackgroundImage = NULL, -#' plotBorderWidth = 0, -#' plotShadow = FALSE -#' ) %>% +#' type = "gauge", +#' plotBackgroundColor = NULL, +#' plotBackgroundImage = NULL, +#' plotBorderWidth = 0, +#' plotShadow = FALSE +#' ) |> #' hc_title( #' text = "Speedometer" -#' ) %>% +#' ) |> #' hc_pane( #' startAngle = -150, #' endAngle = 150, #' background = list(list( #' backgroundColor = list( -#' linearGradient = list(x1 = 0, y1 = 0, x2 = 0, y2 = 1), +#' linearGradient = list( x1 = 0, y1 = 0, x2 = 0, y2 = 1), #' stops = list( #' list(0, "#FFF"), #' list(1, "#333") @@ -637,7 +675,7 @@ hc_loading <- function(hc, ...) { #' outerRadius = "109%" #' ), list( #' backgroundColor = list( -#' linearGradient = list(x1 = 0, y1 = 0, x2 = 0, y2 = 1), +#' linearGradient = list( x1 = 0, y1 = 0, x2 = 0, y2 = 1), #' stops = list( #' list(0, "#333"), #' list(1, "#FFF") @@ -653,23 +691,28 @@ hc_loading <- function(hc, ...) { #' outerRadius = "105%", #' innerRadius = "103%" #' )) -#' ) %>% +#' ) |> #' hc_add_series( #' data = list(80), name = "speed", tooltip = list(valueSuffix = " km/h") -#' ) %>% +#' ) |> +#' +#' #' hc_yAxis( #' min = 0, #' max = 200, +#' #' minorTickInterval = "auto", #' minorTickWidth = 1, #' minorTickLength = 10, #' minorTickPosition = "inside", #' minorTickColor = "#666", +#' #' tickPixelInterval = 30, #' tickWidth = 2, #' tickPosition = "inside", #' tickLength = 10, #' tickColor = "#666", +#' #' labels = list( #' step = 2, #' rotation = "auto" @@ -677,19 +720,25 @@ hc_loading <- function(hc, ...) { #' title = list( #' text = "km/h" #' ), +#' #' plotBands = list( -#' list(from = 0, to = 120, color = "#55BF3B"), +#' list(from = 0, to = 120, color = "#55BF3B"), #' list(from = 120, to = 160, color = "#DDDF0D"), #' list(from = 160, to = 200, color = "#DF5353") #' ) +#' #' ) +#' +#' #' @export hc_pane <- function(hc, ...) { + .hc_opt(hc, "pane", ...) + } #' Plotoptions options for highcharter objects -#' +#' #' The plotOptions is a wrapper object for config objects for each series #' type. The config objects for each series can also be overridden for #' each series item as given in the series array. @@ -698,16 +747,16 @@ hc_pane <- function(hc, ...) { #' type are given in the plotOptions of that type, for example #' plotOptions.line. Next, options for one single series are given in #' the series array. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/plotOptions}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/plotOptions}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_add_series( #' data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) -#' ) %>% +#' ) |> #' hc_plotOptions( #' line = list( #' color = "blue", @@ -715,62 +764,68 @@ hc_pane <- function(hc, ...) { #' fillColor = "white", #' lineWidth = 2, #' lineColor = NULL +#' ) #' ) #' ) -#' ) +#' #' @export hc_plotOptions <- function(hc, ...) { + .hc_opt(hc, "plotOptions", ...) + } #' Responsive options for highcharter objects -#' +#' #' Allows setting a set of rules to apply for different screen or chart #' sizes. Each rule specifies additional chart options. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/responsive}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/responsive}. +#' #' @examples -#' +#' #' leg_500_opts <- list(enabled = FALSE) -#' leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "vertical") -#' -#' +#' leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "vertical") +#' +#' #' # change the with of the container/windows to see the effect -#' highchart() %>% -#' hc_add_series(data = cumsum(rnorm(100))) %>% +#' highchart() |> +#' hc_add_series(data = cumsum(rnorm(100))) |> #' hc_responsive( #' rules = list( #' # remove legend if there is no much space #' list( -#' condition = list(maxWidth = 500), +#' condition = list(maxWidth = 500), #' chartOptions = list(legend = leg_500_opts) #' ), #' # put legend on the right when there is much space #' list( -#' condition = list(minWidth = 900), +#' condition = list(minWidth = 900), #' chartOptions = list(legend = leg_900_opts) #' ) #' ) #' ) +#' #' @export hc_responsive <- function(hc, ...) { + .hc_opt(hc, "responsive", ...) + } #' Series options for highcharter objects -#' +#' #' Series options for specific data and the data itself. In TypeScript you #' have to cast the series options to specific series types, to get all #' possible options for a series. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/series}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/series}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_series( #' list( #' name = "Tokyo", @@ -781,126 +836,136 @@ hc_responsive <- function(hc, ...) { #' data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8) #' ) #' ) +#' #' @export hc_series <- function(hc, ...) { + .hc_opt(hc, "series", ...) + } #' Subtitle options for highcharter objects -#' +#' #' The chart's subtitle. This can be used both to display a subtitle below #' the main title, and to display random text anywhere in the chart. The #' subtitle can be updated after chart initialization through the #' Chart.setTitle method. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/subtitle}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/subtitle}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "column" -#' ) %>% +#' ) |> #' hc_subtitle( #' text = "And this is a subtitle with more information", #' align = "left", #' style = list(color = "#2b908f", fontWeight = "bold") -#' ) +#' ) +#' #' @export hc_subtitle <- function(hc, ...) { + .hc_opt(hc, "subtitle", ...) + } #' Title options for highcharter objects -#' +#' #' The chart's main title. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/title}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/title}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "column" -#' ) %>% +#' ) |> #' hc_title( #' text = "This is a title with margin and Strong or bold text", #' margin = 20, #' align = "left", #' style = list(color = "#22A884", useHTML = TRUE) -#' ) +#' ) +#' #' @export hc_title <- function(hc, ...) { + .hc_opt(hc, "title", ...) + } #' Tooltip options for highcharter objects -#' +#' #' Options for the tooltip that appears when the user hovers over a #' series or point. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/tooltip}. +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/tooltip}. #' @param sort Logical value to implement sort according `this.point` -#' \url{https://stackoverflow.com/a/16954666/829971}. -#' @param table Logical value to implement table in tooltip: -#' \url{https://stackoverflow.com/a/22327749/829971}. -#' +#' \url{http://stackoverflow.com/a/16954666/829971}. +#' @param table Logical value to implement table in tooltip: +#' \url{http://stackoverflow.com/a/22327749/829971}. +#' #' @examples -#' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% -#' hc_add_series(data = sample(1:12) + 10) %>% +#' +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> +#' hc_add_series(data = sample(1:12) + 10) |> #' hc_tooltip( #' crosshairs = TRUE, #' borderWidth = 5, #' sort = TRUE, #' table = TRUE -#' ) +#' ) +#' +#' #' @export hc_tooltip <- function(hc, ..., sort = FALSE, table = FALSE) { - if (sort) { + + if (sort) hc <- .hc_tooltip_sort(hc) - } - - if (table) { + + if (table) hc <- .hc_tooltip_table(hc) - } - - if (length(list(...))) { + + if (length(list(...))) hc <- .hc_opt(hc, "tooltip", ...) - } - - hc + + hc + } #' Xaxis options for highcharter objects -#' +#' #' The X axis or category axis. Normally this is the horizontal axis, #' though if the chart is inverted this is the vertical axis. In case of #' multiple axes, the xAxis node is an array of configuration objects. #' See the Axis class for programmatic #' access to the axis. -#' +#' #' In Highmaps, the axis is hidden, but it is used behind the scenes to #' control features like zooming and panning. Zooming is in effect the same #' as setting the extremes of one of the exes. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/xAxis}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/xAxis}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "spline" -#' ) %>% +#' ) |> #' hc_xAxis( #' title = list(text = "x Axis at top"), #' alternateGridColor = "#FDFFD5", @@ -911,33 +976,36 @@ hc_tooltip <- function(hc, ..., sort = FALSE, table = FALSE) { #' color = "#FF0000", #' width = 2, #' value = 5.5 +#' ) #' ) #' ) -#' ) +#' #' @export hc_xAxis <- function(hc, ...) { + .hc_opt(hc, "xAxis", ...) + } #' Yaxis options for highcharter objects -#' +#' #' The Y axis or value axis. Normally this is the vertical axis, #' though if the chart is inverted this is the horizontal axis. #' In case of multiple axes, the yAxis node is an array of #' configuration objects. #' See the Axis object for programmatic #' access to the axis. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/yAxis}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/yAxis}. +#' #' @examples -#' -#' highchart() %>% +#' +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "spline" -#' ) %>% +#' ) |> #' hc_yAxis( #' title = list(text = "y Axis at right"), #' opposite = TRUE, @@ -952,34 +1020,36 @@ hc_xAxis <- function(hc, ...) { #' to = 17, #' color = "rgba(100, 0, 0, 0.1)", #' label = list(text = "This is a plotBand") +#' ) #' ) -#' ) -#' ) +#' ) +#' #' @export hc_yAxis <- function(hc, ...) { + .hc_opt(hc, "yAxis", ...) + } #' Zaxis options for highcharter objects -#' +#' #' The Z axis or depth axis for 3D plots. #' See the Axis class for programmatic #' access to the axis. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/zAxis}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highcharts/zAxis}. +#' #' @examples -#' +#' #' df <- data.frame( #' x = sample(1:5), #' y = sample(1:5), #' z = sample(1:5) #' ) -#' -#' # Note the 3d requiere highchart2() due have the 3d module -#' highchart2() %>% -#' hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) %>% +#' +#' highchart() |> +#' hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) |> #' hc_chart( #' type = "scatter3d", #' options3d = list( @@ -995,7 +1065,7 @@ hc_yAxis <- function(hc, ...) { #' ) #' ) #' ) -#' ) %>% +#' ) |> #' hc_zAxis( #' title = list(text = "Z axis is here"), #' startOnTick = FALSE, @@ -1005,25 +1075,28 @@ hc_yAxis <- function(hc, ...) { #' gridLineColor = "red", #' gridLineDashStyle = "dot" #' ) +#' #' @export hc_zAxis <- function(hc, ...) { + .hc_opt(hc, "zAxis", ...) + } #' Navigator options for highcharter objects -#' +#' #' The navigator is a small series below the main series, displaying #' a view of the entire data set. It provides tools to zoom in and #' out on parts of the data as well as panning across the dataset. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/navigator}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/navigator}. +#' #' @examples -#' -#' highchart(type = "stock") %>% -#' hc_add_series(AirPassengers) %>% -#' hc_rangeSelector(selected = 4) %>% +#' +#' highchart(type = "stock") |> +#' hc_add_series(AirPassengers) |> +#' hc_rangeSelector(selected = 4) |> #' hc_navigator( #' outlineColor = "gray", #' outlineWidth = 2, @@ -1038,43 +1111,49 @@ hc_zAxis <- function(hc, ...) { #' borderColor = "red" #' ) #' ) +#' #' @export hc_navigator <- function(hc, ...) { + .hc_opt(hc, "navigator", ...) + } #' Rangeselector options for highcharter objects -#' +#' #' The range selector is a tool for selecting ranges to display within #' the chart. It provides buttons to select preconfigured ranges in #' the chart, like 1 day, 1 week, 1 month etc. It also provides input #' boxes where min and max dates can be manually input. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/rangeSelector}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/rangeSelector}. +#' #' @examples -#' -#' hc <- highchart(type = "stock") %>% +#' +#' hc <- highchart(type = "stock") |> #' hc_add_series(AirPassengers) -#' +#' #' hc -#' -#' hc %>% +#' +#' hc |> #' hc_rangeSelector(enabled = FALSE) -#' -#' hc %>% +#' +#' hc |> #' hc_rangeSelector( #' verticalAlign = "bottom", #' selected = 4 -#' ) +#' ) +#' #' @export hc_rangeSelector <- function(hc, ...) { + .hc_opt(hc, "rangeSelector", ...) + } #' Scrollbar options for highcharter objects -#' +#' #' The scrollbar is a means of panning over the X axis of a stock chart. #' Scrollbars can also be applied to other types of axes. #' Another approach to scrollable charts is the chart.scrollablePlotArea option that @@ -1083,15 +1162,15 @@ hc_rangeSelector <- function(hc, ...) { #' scrollbar are replaced by the classes .highcharts-scrollbar-thumb, #' .highcharts-scrollbar-arrow, .highcharts-scrollbar-button, #' .highcharts-scrollbar-rifles and .highcharts-scrollbar-track. -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/scrollbar}. -#' +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highstock/scrollbar}. +#' #' @examples -#' -#' highchart(type = "stock") %>% -#' hc_add_series(AirPassengers) %>% -#' hc_rangeSelector(selected = 4) %>% +#' +#' highchart(type = "stock") |> +#' hc_add_series(AirPassengers) |> +#' hc_rangeSelector(selected = 4) |> #' hc_scrollbar( #' barBackgroundColor = "gray", #' barBorderRadius = 7, @@ -1106,25 +1185,64 @@ hc_rangeSelector <- function(hc, ...) { #' trackBorderColor = "silver", #' trackBorderRadius = 7 #' ) +#' #' @export hc_scrollbar <- function(hc, ...) { + .hc_opt(hc, "scrollbar", ...) + } #' Mapnavigation options for highcharter objects -#' -#' @param hc A `highchart` `htmlwidget` object. -#' @param ... Arguments defined in \url{https://api.highcharts.com/highmaps/mapNavigation}. -#' +#' +#' The mapNavigation option handles buttons for navigation in addition to +#' mousewheel and doubleclick handlers for map zooming. +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highmaps/mapNavigation}. +#' #' @examples -#' -#' hcmap(download_map_data = TRUE) %>% +#' +#' hcmap(download_map_data = FALSE) |> #' hc_mapNavigation( #' enabled = TRUE, #' enableMouseWheelZoom = TRUE, #' enableDoubleClickZoom = TRUE #' ) +#' #' @export hc_mapNavigation <- function(hc, ...) { + .hc_opt(hc, "mapNavigation", ...) + } + +#' Mapview options for highcharter objects +#' +#' The mapView options control the initial view of the chart, and how +#' projection is set up for raw geoJSON maps (beta as of v9.3). +#' To set the view dynamically after chart generation, see +#' mapView.setView. +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highmaps/mapView}. +#' +#' @examples +#' +#' map <- hcmap() +#' +#' map +#' +#' map |> +#' hc_mapView(zoom = 10) |> +#' hc_mapNavigation(enabled = TRUE) +#' +#' +#' +#' @export +hc_mapView <- function(hc, ...) { + + .hc_opt(hc, "mapView", ...) + +} + diff --git a/dev/examples-api/annotations.R b/dev/examples-api/annotations.R index 8ad51416..416de656 100644 --- a/dev/examples-api/annotations.R +++ b/dev/examples-api/annotations.R @@ -1,12 +1,12 @@ # Ex 1 -highchart() %>% +highchart() |> hc_add_series( data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) - ) %>% + ) |> hc_xAxis( tickInterval = 0.5, gridLineWidth = 1 - ) %>% + ) |> hc_annotations( list( labels = @@ -37,8 +37,8 @@ df <- data.frame( y = 1:10 ) -highchart() %>% - hc_add_series(data = df, hcaes(x = x, y = y), type = "area") %>% +highchart() |> + hc_add_series(data = df, hcaes(x = x, y = y), type = "area") |> hc_annotations( list( labels = list( diff --git a/dev/examples-api/boost.R b/dev/examples-api/boost.R index 324921ce..fac2071f 100644 --- a/dev/examples-api/boost.R +++ b/dev/examples-api/boost.R @@ -9,10 +9,10 @@ x <- round(x, 3) plot(x) -hc1 <- highchart() %>% - hc_chart(zoomType = "x") %>% - hc_add_series(data = x) %>% - hc_title(text = "No boost") %>% +hc1 <- highchart() |> + hc_chart(zoomType = "x") |> + hc_add_series(data = x) |> + hc_title(text = "No boost") |> hc_boost( enabled = FALSE # Default ) @@ -23,10 +23,10 @@ hc1 # some of the standard Highcharts features (such as animation), and focuses # on pushing as many points as possible as quickly as possible. -hc2 <- highchart() %>% - hc_chart(zoomType = "x") %>% - hc_add_series(data = x) %>% - hc_title(text = "With boost") %>% +hc2 <- highchart() |> + hc_chart(zoomType = "x") |> + hc_add_series(data = x) |> + hc_title(text = "With boost") |> hc_boost(enabled = TRUE) hc2 @@ -48,17 +48,17 @@ hc2 # # unnamed list # ds <- list_parse2(as.data.frame(mvr)) # -# highchart() %>% -# hc_chart(zoomType = "xy") %>% -# hc_xAxis(min = -vx, max = vx) %>% -# hc_yAxis(min = -vy, max = vy) %>% +# highchart() |> +# hc_chart(zoomType = "xy") |> +# hc_xAxis(min = -vx, max = vx) |> +# hc_yAxis(min = -vy, max = vy) |> # hc_add_series( # data = ds, #list # type = "scatter", # name = "A lot of points!", # color = 'rgba(0,0,0,0.1)', # marker = list(radius = 2) -# ) %>% +# ) |> # hc_boost( # enabled = TRUE # ) @@ -66,10 +66,10 @@ hc2 # dat <- as.data.frame(mvr) # names(dat) <- c("x", "y") # -# highchart() %>% -# hc_chart(zoomType = "xy") %>% -# hc_xAxis(min = -vx, max = vx) %>% -# hc_yAxis(min = -vy, max = vy) %>% +# highchart() |> +# hc_chart(zoomType = "xy") |> +# hc_xAxis(min = -vx, max = vx) |> +# hc_yAxis(min = -vy, max = vy) |> # hc_add_series( # data = dat, # type = "scatter", @@ -77,7 +77,7 @@ hc2 # name = "A lot of points!", # color = 'rgba(0,0,0,0.1)', # marker = list(radius = 2) -# ) %>% +# ) |> # hc_boost(enabled = TRUE) # # # Ex3 @@ -87,13 +87,13 @@ hc2 # s <- s/(max(s) + min(s)) # s <- round(s, 2) # -# series <- s %>% -# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) %>% -# purrr::map(as.vector) %>% -# purrr::map(round, 2) %>% +# series <- s |> +# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) |> +# purrr::map(as.vector) |> +# purrr::map(round, 2) |> # purrr::map(~ list(data = .x)) # -# highchart() %>% -# hc_add_series_list(series) %>% -# hc_chart(zoomType = "x") %>% +# highchart() |> +# hc_add_series_list(series) |> +# hc_chart(zoomType = "x") |> # hc_boost(enabled = TRUE) diff --git a/dev/examples-api/caption.R b/dev/examples-api/caption.R index f25a1d8d..c522c86b 100644 --- a/dev/examples-api/caption.R +++ b/dev/examples-api/caption.R @@ -1,12 +1,12 @@ -highchart() %>% - hc_title(text= "Chart with a caption") %>% - hc_subtitle(text= "This is the subtitle") %>% - hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) %>% +highchart() |> + hc_title(text= "Chart with a caption") |> + hc_subtitle(text= "This is the subtitle") |> + hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) |> hc_add_series( data = c(1, 4, 3, 5), type = "column", name = "Fruits" - ) %>% + ) |> hc_caption( text = "The caption renders in the bottom, and is part of the exported chart.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, diff --git a/dev/examples-api/chart.R b/dev/examples-api/chart.R index 5536898a..c4a7a38c 100644 --- a/dev/examples-api/chart.R +++ b/dev/examples-api/chart.R @@ -1,18 +1,18 @@ -hc <- highchart() %>% - hc_xAxis(categories = month.abb) %>% - hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +hc <- highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_add_series(name = "London", data = sample(1:12) + 10) hc -hc %>% +hc |> hc_chart( type = "column", options3d = list(enabled = TRUE, beta = 15, alpha = 15) ) -hc %>% +hc |> hc_chart( borderColor = "#EBBA95", borderRadius = 10, diff --git a/dev/examples-api/colorAxis.R b/dev/examples-api/colorAxis.R index f0d51684..eabe6ca9 100644 --- a/dev/examples-api/colorAxis.R +++ b/dev/examples-api/colorAxis.R @@ -2,11 +2,12 @@ library(dplyr) data(mpg, package = "ggplot2") -mpgman2 <- mpg %>% - group_by(manufacturer, year) %>% +mpgman2 <- mpg |> + group_by(manufacturer, year) |> dplyr::summarise( n = dplyr::n(), - displ = mean(displ) + displ = mean(displ), + .groups = "drop" ) mpgman2 @@ -16,19 +17,17 @@ hchart( colorKey = "displ", # color = c("#FCA50A", "#FCFFA4"), name = c("Year 1999", "Year 2008") - ) %>% + ) |> hc_colorAxis(min = 0, max = 5) # defaults to yAxis -hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) %>% +hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) |> hc_colorAxis( minColor = "red", maxColor = "blue" ) - - # Ex2 n <- 5 @@ -42,9 +41,9 @@ stops <- list_parse2(stops) M <- round(matrix(rnorm(50*50), ncol = 50), 2) -hchart(M) %>% +hchart(M) |> hc_colorAxis(stops = stops) # Ex3 -# hchart(volcano) %>% -# hc_colorAxis(stops = stops, max = 200) +hchart(volcano) |> + hc_colorAxis(stops = stops, max = 200) diff --git a/dev/examples-api/colors.R b/dev/examples-api/colors.R index e3dc521e..c92e7472 100644 --- a/dev/examples-api/colors.R +++ b/dev/examples-api/colors.R @@ -3,8 +3,8 @@ library(viridisLite) cols <- viridis(3) cols <- substr(cols, 0, 7) -highchart() %>% - hc_add_series(data = sample(1:12)) %>% - hc_add_series(data = sample(1:12) + 10) %>% - hc_add_series(data = sample(1:12) + 20) %>% +highchart() |> + hc_add_series(data = sample(1:12)) |> + hc_add_series(data = sample(1:12) + 10) |> + hc_add_series(data = sample(1:12) + 20) |> hc_colors(cols) diff --git a/dev/examples-api/credits.R b/dev/examples-api/credits.R index c189cb20..118ee51f 100644 --- a/dev/examples-api/credits.R +++ b/dev/examples-api/credits.R @@ -1,6 +1,6 @@ -highchart() %>% - hc_xAxis(categories = citytemp$month) %>% - hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +highchart() |> + hc_xAxis(categories = citytemp$month) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_credits( enabled = TRUE, text = "htmlwidgets.org", diff --git a/dev/examples-api/drilldown.R b/dev/examples-api/drilldown.R index 20b6cd61..13635087 100644 --- a/dev/examples-api/drilldown.R +++ b/dev/examples-api/drilldown.R @@ -10,16 +10,16 @@ df <- tibble( df -hc <- highchart() %>% - hc_title(text = "Basic drilldown") %>% - hc_xAxis(type = "category") %>% - hc_legend(enabled = FALSE) %>% +hc <- highchart() |> + hc_title(text = "Basic drilldown") |> + hc_xAxis(type = "category") |> + hc_legend(enabled = FALSE) |> hc_plotOptions( series = list( boderWidth = 0, dataLabels = list(enabled = TRUE) ) - ) %>% + ) |> hc_add_series( data = df, type = "column", @@ -43,7 +43,7 @@ dsan <- list_parse2(dfan) dsfru <- list_parse2(dffru) -hc <- hc %>% +hc <- hc |> hc_drilldown( allowPointDrilldown = TRUE, series = list( diff --git a/dev/examples-api/exporting.R b/dev/examples-api/exporting.R index b45ee000..2e7b3563 100644 --- a/dev/examples-api/exporting.R +++ b/dev/examples-api/exporting.R @@ -1,6 +1,6 @@ -highchart() %>% - hc_xAxis(categories = month.abb) %>% - hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_exporting( enabled = TRUE, # always enabled filename = "custom-file-name" diff --git a/dev/examples-api/labels.R b/dev/examples-api/labels.R index c074805b..a4f5da41 100644 --- a/dev/examples-api/labels.R +++ b/dev/examples-api/labels.R @@ -1,5 +1,5 @@ -highchart() %>% - hc_add_series(data = sample(1:12)) %>% +highchart() |> + hc_add_series(data = sample(1:12)) |> hc_labels( items = list( list( diff --git a/dev/examples-api/legend.R b/dev/examples-api/legend.R index 7c03979a..3d744337 100644 --- a/dev/examples-api/legend.R +++ b/dev/examples-api/legend.R @@ -1,8 +1,8 @@ -highchart() %>% - hc_xAxis(categories = month.abb) %>% - hc_add_series(name = "Tokyo", data = sample(1:12)) %>% - hc_add_series(name = "London", data = sample(1:12) + 10) %>% - hc_add_series(name = "Other City", data = sample(1:12) + 20) %>% +highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> + hc_add_series(name = "London", data = sample(1:12) + 10) |> + hc_add_series(name = "Other City", data = sample(1:12) + 20) |> hc_legend( align = "left", verticalAlign = "top", diff --git a/dev/examples-api/loading.R b/dev/examples-api/loading.R index 577e1539..240a796f 100644 --- a/dev/examples-api/loading.R +++ b/dev/examples-api/loading.R @@ -1,4 +1,4 @@ -highcharts_demo() %>% +highcharts_demo() |> hc_loading( hideDuration = 1000, showDuration = 1000 diff --git a/dev/examples-api/mapNavigation.R b/dev/examples-api/mapNavigation.R index 1f1bc4cd..5eb235ba 100644 --- a/dev/examples-api/mapNavigation.R +++ b/dev/examples-api/mapNavigation.R @@ -1,4 +1,4 @@ -hcmap(download_map_data = FALSE) %>% +hcmap(download_map_data = FALSE) |> hc_mapNavigation( enabled = TRUE, enableMouseWheelZoom = TRUE, diff --git a/dev/examples-api/navigator.R b/dev/examples-api/navigator.R index 5605c724..e37e8da9 100644 --- a/dev/examples-api/navigator.R +++ b/dev/examples-api/navigator.R @@ -1,6 +1,6 @@ -highchart(type = "stock") %>% - hc_add_series(AirPassengers) %>% - hc_rangeSelector(selected = 4) %>% +highchart(type = "stock") |> + hc_add_series(AirPassengers) |> + hc_rangeSelector(selected = 4) |> hc_navigator( outlineColor = "gray", outlineWidth = 2, diff --git a/dev/examples-api/pane.R b/dev/examples-api/pane.R index 8c606474..446486a2 100644 --- a/dev/examples-api/pane.R +++ b/dev/examples-api/pane.R @@ -1,14 +1,14 @@ -highchart() %>% +highchart() |> hc_chart( type = "gauge", plotBackgroundColor = NULL, plotBackgroundImage = NULL, plotBorderWidth = 0, plotShadow = FALSE - ) %>% + ) |> hc_title( text = "Speedometer" - ) %>% + ) |> hc_pane( startAngle = -150, endAngle = 150, @@ -40,10 +40,10 @@ highchart() %>% outerRadius = "105%", innerRadius = "103%" )) - ) %>% + ) |> hc_add_series( data = list(80), name = "speed", tooltip = list(valueSuffix = " km/h") - ) %>% + ) |> hc_yAxis( diff --git a/dev/examples-api/plotOptions.R b/dev/examples-api/plotOptions.R index 857d2cc3..14ff42c2 100644 --- a/dev/examples-api/plotOptions.R +++ b/dev/examples-api/plotOptions.R @@ -1,7 +1,7 @@ -highchart() %>% +highchart() |> hc_add_series( data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) - ) %>% + ) |> hc_plotOptions( line = list( color = "blue", diff --git a/dev/examples-api/rangeSelector.R b/dev/examples-api/rangeSelector.R index 70cbb08c..79adf1f4 100644 --- a/dev/examples-api/rangeSelector.R +++ b/dev/examples-api/rangeSelector.R @@ -1,12 +1,12 @@ -hc <- highchart(type = "stock") %>% +hc <- highchart(type = "stock") |> hc_add_series(AirPassengers) hc -hc %>% +hc |> hc_rangeSelector(enabled = FALSE) -hc %>% +hc |> hc_rangeSelector( verticalAlign = "bottom", selected = 4 diff --git a/dev/examples-api/responsive.R b/dev/examples-api/responsive.R index 8c5398a6..827e3e24 100644 --- a/dev/examples-api/responsive.R +++ b/dev/examples-api/responsive.R @@ -3,8 +3,8 @@ leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "verti # change the with of the container/windows to see the effect -highchart() %>% - hc_add_series(data = cumsum(rnorm(100))) %>% +highchart() |> + hc_add_series(data = cumsum(rnorm(100))) |> hc_responsive( rules = list( # remove legend if there is no much space diff --git a/dev/examples-api/scrollbar.R b/dev/examples-api/scrollbar.R index bd0f9c2a..1c8497ee 100644 --- a/dev/examples-api/scrollbar.R +++ b/dev/examples-api/scrollbar.R @@ -1,6 +1,6 @@ -highchart(type = "stock") %>% - hc_add_series(AirPassengers) %>% - hc_rangeSelector(selected = 4) %>% +highchart(type = "stock") |> + hc_add_series(AirPassengers) |> + hc_rangeSelector(selected = 4) |> hc_scrollbar( barBackgroundColor = "gray", barBorderRadius = 7, diff --git a/dev/examples-api/series.R b/dev/examples-api/series.R index 7c7429ab..ef120c90 100644 --- a/dev/examples-api/series.R +++ b/dev/examples-api/series.R @@ -1,4 +1,4 @@ -highchart() %>% +highchart() |> hc_series( list( name = "Tokyo", diff --git a/dev/examples-api/subtitle.R b/dev/examples-api/subtitle.R index 81276b37..93f76e7a 100644 --- a/dev/examples-api/subtitle.R +++ b/dev/examples-api/subtitle.R @@ -1,8 +1,8 @@ -highchart() %>% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "column" - ) %>% + ) |> hc_subtitle( text = "And this is a subtitle with more information", align = "left", diff --git a/dev/examples-api/time.R b/dev/examples-api/time.R index cb418d64..acc9d709 100644 --- a/dev/examples-api/time.R +++ b/dev/examples-api/time.R @@ -1,17 +1,17 @@ -hc <- highchart() %>% +hc <- highchart() |> hc_add_series( data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4), pointStart = JS("Date.UTC(2017, 0, 1)"), pointInterval = 36e5 - ) %>% + ) |> hc_xAxis( type = "datetime" ) -hc %>% - hc_title(text = "Berlin Time") %>% +hc |> + hc_title(text = "Berlin Time") |> hc_time(timezone = "Europe/Berlin") -hc %>% - hc_title(text = "New York Time") %>% +hc |> + hc_title(text = "New York Time") |> hc_time(timezone = "America/New_York") diff --git a/dev/examples-api/title.R b/dev/examples-api/title.R index d8969a5d..e6f90875 100644 --- a/dev/examples-api/title.R +++ b/dev/examples-api/title.R @@ -1,8 +1,8 @@ -highchart() %>% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "column" - ) %>% + ) |> hc_title( text = "This is a title with margin and Strong or bold text", margin = 20, diff --git a/dev/examples-api/tooltip.R b/dev/examples-api/tooltip.R index 8c2eb888..2ac7ce2d 100644 --- a/dev/examples-api/tooltip.R +++ b/dev/examples-api/tooltip.R @@ -1,6 +1,6 @@ -highchart() %>% - hc_add_series(data = sample(1:12)) %>% - hc_add_series(data = sample(1:12) + 10) %>% +highchart() |> + hc_add_series(data = sample(1:12)) |> + hc_add_series(data = sample(1:12) + 10) |> hc_tooltip( crosshairs = TRUE, borderWidth = 5, diff --git a/dev/examples-api/xAxis.R b/dev/examples-api/xAxis.R index 1ae32eed..de0f05e2 100644 --- a/dev/examples-api/xAxis.R +++ b/dev/examples-api/xAxis.R @@ -1,8 +1,8 @@ -highchart() %>% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "spline" - ) %>% + ) |> hc_xAxis( title = list(text = "x Axis at top"), alternateGridColor = "#FDFFD5", diff --git a/dev/examples-api/yAxis.R b/dev/examples-api/yAxis.R index fe005443..926bf0ca 100644 --- a/dev/examples-api/yAxis.R +++ b/dev/examples-api/yAxis.R @@ -1,8 +1,8 @@ -highchart() %>% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "spline" - ) %>% + ) |> hc_yAxis( title = list(text = "y Axis at right"), opposite = TRUE, diff --git a/dev/examples-api/zAxis.R b/dev/examples-api/zAxis.R index 2d4aa090..11425d6c 100644 --- a/dev/examples-api/zAxis.R +++ b/dev/examples-api/zAxis.R @@ -4,8 +4,8 @@ df <- data.frame( z = sample(1:5) ) -highchart() %>% - hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) %>% +highchart() |> + hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) |> hc_chart( type = "scatter3d", options3d = list( @@ -21,7 +21,7 @@ highchart() %>% ) ) ) - ) %>% + ) |> hc_zAxis( title = list(text = "Z axis is here"), startOnTick = FALSE, diff --git a/dev/generate-highcharts-api.R b/dev/generate-highcharts-api.R index 17e66866..8422e3c5 100644 --- a/dev/generate-highcharts-api.R +++ b/dev/generate-highcharts-api.R @@ -50,7 +50,7 @@ dfopts <- dfopts %>% # run examples for each function ------------------------------------------ # run examples to check at least don't have errors -# dont assing if you want to see the outputs +# don't assign if you want to see the outputs dfopts %>% pull(option) %>% str_c("dev/examples-api/", ., ".R") %>% @@ -237,7 +237,7 @@ file.copy( overwrite = TRUE ) -message("devtools::document() & devtools::build()") +cli::cli_h1("devtools::document() & devtools::build()") devtools::document() devtools::build() diff --git a/dev/highcharts-api.R b/dev/highcharts-api.R index cc7578fd..95dd0a45 100644 --- a/dev/highcharts-api.R +++ b/dev/highcharts-api.R @@ -1,5 +1,5 @@ # Generated by 'dev/generate-highcharts-api.R' -# Generated in 2021-02-02 12:43:12 +# Generated in 2022-08-07 20:58:21 # #' Annotations options for highcharter objects @@ -14,14 +14,14 @@ #' @examples #' #' # Ex 1 -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) -#' ) %>% +#' ) |> #' hc_xAxis( #' tickInterval = 0.5, #' gridLineWidth = 1 -#' ) %>% +#' ) |> #' hc_annotations( #' list( #' labels = @@ -52,8 +52,8 @@ #' y = 1:10 #' ) #' -#' highchart() %>% -#' hc_add_series(data = df, hcaes(x = x, y = y), type = "area") %>% +#' highchart() |> +#' hc_add_series(data = df, hcaes(x = x, y = y), type = "area") |> #' hc_annotations( #' list( #' labels = list( @@ -100,10 +100,10 @@ hc_annotations <- function(hc, ...) { #' #' plot(x) #' -#' hc1 <- highchart() %>% -#' hc_chart(zoomType = "x") %>% -#' hc_add_series(data = x) %>% -#' hc_title(text = "No boost") %>% +#' hc1 <- highchart() |> +#' hc_chart(zoomType = "x") |> +#' hc_add_series(data = x) |> +#' hc_title(text = "No boost") |> #' hc_boost( #' enabled = FALSE # Default #' ) @@ -114,10 +114,10 @@ hc_annotations <- function(hc, ...) { #' # some of the standard Highcharts features (such as animation), and focuses #' # on pushing as many points as possible as quickly as possible. #' -#' hc2 <- highchart() %>% -#' hc_chart(zoomType = "x") %>% -#' hc_add_series(data = x) %>% -#' hc_title(text = "With boost") %>% +#' hc2 <- highchart() |> +#' hc_chart(zoomType = "x") |> +#' hc_add_series(data = x) |> +#' hc_title(text = "With boost") |> #' hc_boost(enabled = TRUE) #' #' hc2 @@ -139,17 +139,17 @@ hc_annotations <- function(hc, ...) { #' # # unnamed list #' # ds <- list_parse2(as.data.frame(mvr)) #' # -#' # highchart() %>% -#' # hc_chart(zoomType = "xy") %>% -#' # hc_xAxis(min = -vx, max = vx) %>% -#' # hc_yAxis(min = -vy, max = vy) %>% +#' # highchart() |> +#' # hc_chart(zoomType = "xy") |> +#' # hc_xAxis(min = -vx, max = vx) |> +#' # hc_yAxis(min = -vy, max = vy) |> #' # hc_add_series( #' # data = ds, #list #' # type = "scatter", #' # name = "A lot of points!", #' # color = 'rgba(0,0,0,0.1)', #' # marker = list(radius = 2) -#' # ) %>% +#' # ) |> #' # hc_boost( #' # enabled = TRUE #' # ) @@ -157,10 +157,10 @@ hc_annotations <- function(hc, ...) { #' # dat <- as.data.frame(mvr) #' # names(dat) <- c("x", "y") #' # -#' # highchart() %>% -#' # hc_chart(zoomType = "xy") %>% -#' # hc_xAxis(min = -vx, max = vx) %>% -#' # hc_yAxis(min = -vy, max = vy) %>% +#' # highchart() |> +#' # hc_chart(zoomType = "xy") |> +#' # hc_xAxis(min = -vx, max = vx) |> +#' # hc_yAxis(min = -vy, max = vy) |> #' # hc_add_series( #' # data = dat, #' # type = "scatter", @@ -168,7 +168,7 @@ hc_annotations <- function(hc, ...) { #' # name = "A lot of points!", #' # color = 'rgba(0,0,0,0.1)', #' # marker = list(radius = 2) -#' # ) %>% +#' # ) |> #' # hc_boost(enabled = TRUE) #' # #' # # Ex3 @@ -178,15 +178,15 @@ hc_annotations <- function(hc, ...) { #' # s <- s/(max(s) + min(s)) #' # s <- round(s, 2) #' # -#' # series <- s %>% -#' # purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) %>% -#' # purrr::map(as.vector) %>% -#' # purrr::map(round, 2) %>% +#' # series <- s |> +#' # purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) |> +#' # purrr::map(as.vector) |> +#' # purrr::map(round, 2) |> #' # purrr::map(~ list(data = .x)) #' # -#' # highchart() %>% -#' # hc_add_series_list(series) %>% -#' # hc_chart(zoomType = "x") %>% +#' # highchart() |> +#' # hc_add_series_list(series) |> +#' # hc_chart(zoomType = "x") |> #' # hc_boost(enabled = TRUE) #' #' @export @@ -207,15 +207,15 @@ hc_boost <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% -#' hc_title(text= "Chart with a caption") %>% -#' hc_subtitle(text= "This is the subtitle") %>% -#' hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) %>% +#' highchart() |> +#' hc_title(text= "Chart with a caption") |> +#' hc_subtitle(text= "This is the subtitle") |> +#' hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) |> #' hc_add_series( #' data = c(1, 4, 3, 5), #' type = "column", #' name = "Fruits" -#' ) %>% +#' ) |> #' hc_caption( #' text = "The caption renders in the bottom, and is part of the exported #' chart.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, @@ -243,21 +243,21 @@ hc_caption <- function(hc, ...) { #' #' @examples #' -#' hc <- highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' hc <- highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_add_series(name = "London", data = sample(1:12) + 10) #' #' hc #' -#' hc %>% +#' hc |> #' hc_chart( #' type = "column", #' options3d = list(enabled = TRUE, beta = 15, alpha = 15) #' ) #' #' -#' hc %>% +#' hc |> #' hc_chart( #' borderColor = "#EBBA95", #' borderRadius = 10, @@ -317,11 +317,12 @@ hc_chart <- function(hc, ...) { #' #' data(mpg, package = "ggplot2") #' -#' mpgman2 <- mpg %>% -#' group_by(manufacturer, year) %>% +#' mpgman2 <- mpg |> +#' group_by(manufacturer, year) |> #' dplyr::summarise( #' n = dplyr::n(), -#' displ = mean(displ) +#' displ = mean(displ), +#' .groups = "drop" #' ) #' #' mpgman2 @@ -331,19 +332,17 @@ hc_chart <- function(hc, ...) { #' colorKey = "displ", #' # color = c("#FCA50A", "#FCFFA4"), #' name = c("Year 1999", "Year 2008") -#' ) %>% +#' ) |> #' hc_colorAxis(min = 0, max = 5) #' #' #' # defaults to yAxis -#' hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) %>% +#' hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) |> #' hc_colorAxis( #' minColor = "red", #' maxColor = "blue" #' ) #' -#' -#' #' # Ex2 #' n <- 5 #' @@ -357,12 +356,12 @@ hc_chart <- function(hc, ...) { #' #' M <- round(matrix(rnorm(50*50), ncol = 50), 2) #' -#' hchart(M) %>% +#' hchart(M) |> #' hc_colorAxis(stops = stops) #' #' # Ex3 -#' # hchart(volcano) %>% -#' # hc_colorAxis(stops = stops, max = 200) +#' hchart(volcano) |> +#' hc_colorAxis(stops = stops, max = 200) #' #' @export hc_colorAxis <- function(hc, ...) { @@ -386,10 +385,10 @@ hc_colorAxis <- function(hc, ...) { #' cols <- viridis(3) #' cols <- substr(cols, 0, 7) #' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% -#' hc_add_series(data = sample(1:12) + 10) %>% -#' hc_add_series(data = sample(1:12) + 20) %>% +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> +#' hc_add_series(data = sample(1:12) + 10) |> +#' hc_add_series(data = sample(1:12) + 20) |> #' hc_colors(cols) #' #' @export @@ -417,9 +416,9 @@ hc_colors <- function(hc, colors) { #' #' @examples #' -#' highchart() %>% -#' hc_xAxis(categories = citytemp$month) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' highchart() |> +#' hc_xAxis(categories = citytemp$month) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_credits( #' enabled = TRUE, #' text = "htmlwidgets.org", @@ -458,16 +457,16 @@ hc_credits <- function(hc, ...) { #' #' df #' -#' hc <- highchart() %>% -#' hc_title(text = "Basic drilldown") %>% -#' hc_xAxis(type = "category") %>% -#' hc_legend(enabled = FALSE) %>% +#' hc <- highchart() |> +#' hc_title(text = "Basic drilldown") |> +#' hc_xAxis(type = "category") |> +#' hc_legend(enabled = FALSE) |> #' hc_plotOptions( #' series = list( #' boderWidth = 0, #' dataLabels = list(enabled = TRUE) #' ) -#' ) %>% +#' ) |> #' hc_add_series( #' data = df, #' type = "column", @@ -491,7 +490,7 @@ hc_credits <- function(hc, ...) { #' #' dsfru <- list_parse2(dffru) #' -#' hc <- hc %>% +#' hc <- hc |> #' hc_drilldown( #' allowPointDrilldown = TRUE, #' series = list( @@ -527,9 +526,9 @@ hc_drilldown <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% +#' highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> #' hc_exporting( #' enabled = TRUE, # always enabled #' filename = "custom-file-name" @@ -553,8 +552,8 @@ hc_exporting <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> #' hc_labels( #' items = list( #' list( @@ -592,11 +591,11 @@ hc_labels <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% -#' hc_xAxis(categories = month.abb) %>% -#' hc_add_series(name = "Tokyo", data = sample(1:12)) %>% -#' hc_add_series(name = "London", data = sample(1:12) + 10) %>% -#' hc_add_series(name = "Other City", data = sample(1:12) + 20) %>% +#' highchart() |> +#' hc_xAxis(categories = month.abb) |> +#' hc_add_series(name = "Tokyo", data = sample(1:12)) |> +#' hc_add_series(name = "London", data = sample(1:12) + 10) |> +#' hc_add_series(name = "Other City", data = sample(1:12) + 20) |> #' hc_legend( #' align = "left", #' verticalAlign = "top", @@ -627,7 +626,7 @@ hc_legend <- function(hc, ...) { #' #' @examples #' -#' highcharts_demo() %>% +#' highcharts_demo() |> #' hc_loading( #' hideDuration = 1000, #' showDuration = 1000 @@ -650,17 +649,17 @@ hc_loading <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_chart( #' type = "gauge", #' plotBackgroundColor = NULL, #' plotBackgroundImage = NULL, #' plotBorderWidth = 0, #' plotShadow = FALSE -#' ) %>% +#' ) |> #' hc_title( #' text = "Speedometer" -#' ) %>% +#' ) |> #' hc_pane( #' startAngle = -150, #' endAngle = 150, @@ -692,10 +691,10 @@ hc_loading <- function(hc, ...) { #' outerRadius = "105%", #' innerRadius = "103%" #' )) -#' ) %>% +#' ) |> #' hc_add_series( #' data = list(80), name = "speed", tooltip = list(valueSuffix = " km/h") -#' ) %>% +#' ) |> #' #' #' hc_yAxis( @@ -754,10 +753,10 @@ hc_pane <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) -#' ) %>% +#' ) |> #' hc_plotOptions( #' line = list( #' color = "blue", @@ -791,8 +790,8 @@ hc_plotOptions <- function(hc, ...) { #' #' #' # change the with of the container/windows to see the effect -#' highchart() %>% -#' hc_add_series(data = cumsum(rnorm(100))) %>% +#' highchart() |> +#' hc_add_series(data = cumsum(rnorm(100))) |> #' hc_responsive( #' rules = list( #' # remove legend if there is no much space @@ -826,7 +825,7 @@ hc_responsive <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_series( #' list( #' name = "Tokyo", @@ -857,11 +856,11 @@ hc_series <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "column" -#' ) %>% +#' ) |> #' hc_subtitle( #' text = "And this is a subtitle with more information", #' align = "left", @@ -884,11 +883,11 @@ hc_subtitle <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "column" -#' ) %>% +#' ) |> #' hc_title( #' text = "This is a title with margin and Strong or bold text", #' margin = 20, @@ -917,9 +916,9 @@ hc_title <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% -#' hc_add_series(data = sample(1:12)) %>% -#' hc_add_series(data = sample(1:12) + 10) %>% +#' highchart() |> +#' hc_add_series(data = sample(1:12)) |> +#' hc_add_series(data = sample(1:12) + 10) |> #' hc_tooltip( #' crosshairs = TRUE, #' borderWidth = 5, @@ -962,11 +961,11 @@ hc_tooltip <- function(hc, ..., sort = FALSE, table = FALSE) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "spline" -#' ) %>% +#' ) |> #' hc_xAxis( #' title = list(text = "x Axis at top"), #' alternateGridColor = "#FDFFD5", @@ -1002,11 +1001,11 @@ hc_xAxis <- function(hc, ...) { #' #' @examples #' -#' highchart() %>% +#' highchart() |> #' hc_add_series( #' data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), #' type = "spline" -#' ) %>% +#' ) |> #' hc_yAxis( #' title = list(text = "y Axis at right"), #' opposite = TRUE, @@ -1049,9 +1048,8 @@ hc_yAxis <- function(hc, ...) { #' z = sample(1:5) #' ) #' -#' # Note the 3d requiere highchart2() due have the 3d module -#' highchart2() %>% -#' hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) %>% +#' highchart() |> +#' hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) |> #' hc_chart( #' type = "scatter3d", #' options3d = list( @@ -1067,7 +1065,7 @@ hc_yAxis <- function(hc, ...) { #' ) #' ) #' ) -#' ) %>% +#' ) |> #' hc_zAxis( #' title = list(text = "Z axis is here"), #' startOnTick = FALSE, @@ -1096,9 +1094,9 @@ hc_zAxis <- function(hc, ...) { #' #' @examples #' -#' highchart(type = "stock") %>% -#' hc_add_series(AirPassengers) %>% -#' hc_rangeSelector(selected = 4) %>% +#' highchart(type = "stock") |> +#' hc_add_series(AirPassengers) |> +#' hc_rangeSelector(selected = 4) |> #' hc_navigator( #' outlineColor = "gray", #' outlineWidth = 2, @@ -1133,15 +1131,15 @@ hc_navigator <- function(hc, ...) { #' #' @examples #' -#' hc <- highchart(type = "stock") %>% +#' hc <- highchart(type = "stock") |> #' hc_add_series(AirPassengers) #' #' hc #' -#' hc %>% +#' hc |> #' hc_rangeSelector(enabled = FALSE) #' -#' hc %>% +#' hc |> #' hc_rangeSelector( #' verticalAlign = "bottom", #' selected = 4 @@ -1170,9 +1168,9 @@ hc_rangeSelector <- function(hc, ...) { #' #' @examples #' -#' highchart(type = "stock") %>% -#' hc_add_series(AirPassengers) %>% -#' hc_rangeSelector(selected = 4) %>% +#' highchart(type = "stock") |> +#' hc_add_series(AirPassengers) |> +#' hc_rangeSelector(selected = 4) |> #' hc_scrollbar( #' barBackgroundColor = "gray", #' barBorderRadius = 7, @@ -1197,12 +1195,15 @@ hc_scrollbar <- function(hc, ...) { #' Mapnavigation options for highcharter objects #' +#' The mapNavigation option handles buttons for navigation in addition to +#' mousewheel and doubleclick handlers for map zooming. +#' #' @param hc A `highchart` `htmlwidget` object. #' @param ... Arguments defined in \url{https://api.highcharts.com/highmaps/mapNavigation}. #' #' @examples #' -#' hcmap(download_map_data = FALSE) %>% +#' hcmap(download_map_data = FALSE) |> #' hc_mapNavigation( #' enabled = TRUE, #' enableMouseWheelZoom = TRUE, @@ -1216,3 +1217,32 @@ hc_mapNavigation <- function(hc, ...) { } +#' Mapview options for highcharter objects +#' +#' The mapView options control the initial view of the chart, and how +#' projection is set up for raw geoJSON maps (beta as of v9.3). +#' To set the view dynamically after chart generation, see +#' mapView.setView. +#' +#' @param hc A `highchart` `htmlwidget` object. +#' @param ... Arguments defined in \url{https://api.highcharts.com/highmaps/mapView}. +#' +#' @examples +#' +#' map <- hcmap() +#' +#' map +#' +#' map |> +#' hc_mapView(zoom = 10) |> +#' hc_mapNavigation(enabled = TRUE) +#' +#' +#' +#' @export +hc_mapView <- function(hc, ...) { + + .hc_opt(hc, "mapView", ...) + +} + diff --git a/man/hc_annotations.Rd b/man/hc_annotations.Rd index 18e705b0..b1be3181 100644 --- a/man/hc_annotations.Rd +++ b/man/hc_annotations.Rd @@ -19,46 +19,46 @@ or chart pixel coordinates. \examples{ # Ex 1 -highchart() \%>\% +highchart() |> hc_add_series( data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) - ) \%>\% + ) |> hc_xAxis( tickInterval = 0.5, - gridLineWidth = 1 - ) \%>\% + gridLineWidth = 1 + ) |> hc_annotations( list( - labels = + labels = list( list( point = list(x = 3, y = 129.2, xAxis = 0, yAxis = 0), text = "x: {x}
y: {y}" - ), + ), list( point = list(x = 9, y = 194.1, xAxis = 0, yAxis = 0), text = "x: {x}
y: {y}" - ), + ), list( point = list(x = 5, y = 100, xAxis = 0), text = "x: {x}
y: {point.plotY} px" - ), + ), list( point = list(x = 0, y = 0), text = "x: {point.plotX} px
y: {point.plotY} px" + ) ) - ) + ) ) - ) - + # Ex 2 df <- data.frame( x = 1:10, y = 1:10 ) -highchart() \%>\% - hc_add_series(data = df, hcaes(x = x, y = y), type = "area") \%>\% +highchart() |> + hc_add_series(data = df, hcaes(x = x, y = y), type = "area") |> hc_annotations( list( labels = list( @@ -67,4 +67,5 @@ highchart() \%>\% ) ) ) + } diff --git a/man/hc_boost.Rd b/man/hc_boost.Rd index 7fc6bb96..a04f04aa 100644 --- a/man/hc_boost.Rd +++ b/man/hc_boost.Rd @@ -31,16 +31,16 @@ options(highcharter.rjson = FALSE) n <- 50000 -x <- sin(4 * 2 * pi * seq(n) / n) + rnorm(n) / 10 +x <- sin(4*2*pi*seq(n)/n) + rnorm(n)/10 x <- round(x, 3) plot(x) -hc1 <- highchart() \%>\% - hc_chart(zoomType = "x") \%>\% - hc_add_series(data = x) \%>\% - hc_title(text = "No boost") \%>\% +hc1 <- highchart() |> + hc_chart(zoomType = "x") |> + hc_add_series(data = x) |> + hc_title(text = "No boost") |> hc_boost( enabled = FALSE # Default ) @@ -51,10 +51,10 @@ hc1 # some of the standard Highcharts features (such as animation), and focuses # on pushing as many points as possible as quickly as possible. -hc2 <- highchart() \%>\% - hc_chart(zoomType = "x") \%>\% - hc_add_series(data = x) \%>\% - hc_title(text = "With boost") \%>\% +hc2 <- highchart() |> + hc_chart(zoomType = "x") |> + hc_add_series(data = x) |> + hc_title(text = "With boost") |> hc_boost(enabled = TRUE) hc2 @@ -62,42 +62,42 @@ hc2 # # Ex 2 # library(MASS) -# +# # n <- 20000 -# +# # sigma <- matrix(c(10,3,3,2),2,2) # sigma -# +# # mvr <- round(mvrnorm(n, rep(c(0, 0)), sigma), 2) -# +# # vx <- ceiling(1+abs(max(mvr[, 1]))) # vy <- ceiling(1+abs(max(mvr[, 2]))) -# +# # # unnamed list # ds <- list_parse2(as.data.frame(mvr)) -# -# highchart() \%>\% -# hc_chart(zoomType = "xy") \%>\% -# hc_xAxis(min = -vx, max = vx) \%>\% -# hc_yAxis(min = -vy, max = vy) \%>\% +# +# highchart() |> +# hc_chart(zoomType = "xy") |> +# hc_xAxis(min = -vx, max = vx) |> +# hc_yAxis(min = -vy, max = vy) |> # hc_add_series( # data = ds, #list # type = "scatter", # name = "A lot of points!", # color = 'rgba(0,0,0,0.1)', # marker = list(radius = 2) -# ) \%>\% +# ) |> # hc_boost( -# enabled = TRUE +# enabled = TRUE # ) -# +# # dat <- as.data.frame(mvr) # names(dat) <- c("x", "y") -# -# highchart() \%>\% -# hc_chart(zoomType = "xy") \%>\% -# hc_xAxis(min = -vx, max = vx) \%>\% -# hc_yAxis(min = -vy, max = vy) \%>\% +# +# highchart() |> +# hc_chart(zoomType = "xy") |> +# hc_xAxis(min = -vx, max = vx) |> +# hc_yAxis(min = -vy, max = vy) |> # hc_add_series( # data = dat, # type = "scatter", @@ -105,24 +105,25 @@ hc2 # name = "A lot of points!", # color = 'rgba(0,0,0,0.1)', # marker = list(radius = 2) -# ) \%>\% +# ) |> # hc_boost(enabled = TRUE) -# +# # # Ex3 # N <- 1000000 # n <- 5 # s <- seq(n) # s <- s/(max(s) + min(s)) # s <- round(s, 2) -# -# series <- s \%>\% -# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) \%>\% -# purrr::map(as.vector) \%>\% -# purrr::map(round, 2) \%>\% +# +# series <- s |> +# purrr::map(~ stats::arima.sim(round(N/n), model = list(ar = .x)) + .x * n * 20) |> +# purrr::map(as.vector) |> +# purrr::map(round, 2) |> # purrr::map(~ list(data = .x)) -# -# highchart() \%>\% -# hc_add_series_list(series) \%>\% -# hc_chart(zoomType = "x") \%>\% +# +# highchart() |> +# hc_add_series_list(series) |> +# hc_chart(zoomType = "x") |> # hc_boost(enabled = TRUE) + } diff --git a/man/hc_caption.Rd b/man/hc_caption.Rd index 44249260..ff13f3b2 100644 --- a/man/hc_caption.Rd +++ b/man/hc_caption.Rd @@ -18,23 +18,24 @@ through the Chart.update or Chart.caption.update methods. } \examples{ -highchart() \%>\% - hc_title(text = "Chart with a caption") \%>\% - hc_subtitle(text = "This is the subtitle") \%>\% - hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) \%>\% +highchart() |> + hc_title(text= "Chart with a caption") |> + hc_subtitle(text= "This is the subtitle") |> + hc_xAxis(categories = c("Apples", "Pears", "Banana", "Orange")) |> hc_add_series( data = c(1, 4, 3, 5), type = "column", name = "Fruits" - ) \%>\% + ) |> hc_caption( text = "The caption renders in the bottom, and is part of the exported chart.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim - ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate - velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'" ) + } diff --git a/man/hc_chart.Rd b/man/hc_chart.Rd index 8f7a298f..c46a5d1e 100644 --- a/man/hc_chart.Rd +++ b/man/hc_chart.Rd @@ -16,21 +16,21 @@ General options for the chart. } \examples{ -hc <- highchart() \%>\% - hc_xAxis(categories = month.abb) \%>\% - hc_add_series(name = "Tokyo", data = sample(1:12)) \%>\% +hc <- highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_add_series(name = "London", data = sample(1:12) + 10) hc -hc \%>\% +hc |> hc_chart( type = "column", options3d = list(enabled = TRUE, beta = 15, alpha = 15) - ) + ) -hc \%>\% +hc |> hc_chart( borderColor = "#EBBA95", borderRadius = 10, @@ -38,9 +38,11 @@ hc \%>\% backgroundColor = list( linearGradient = c(0, 0, 500, 500), stops = list( - list(0, "rgb(255, 255, 255)"), - list(1, "rgb(200, 200, 255)") + list(0, 'rgb(255, 255, 255)'), + list(1, 'rgb(200, 200, 255)') + ) ) ) - ) + + } diff --git a/man/hc_colorAxis.Rd b/man/hc_colorAxis.Rd index 437def3b..793c5f0b 100644 --- a/man/hc_colorAxis.Rd +++ b/man/hc_colorAxis.Rd @@ -45,12 +45,13 @@ library(dplyr) data(mpg, package = "ggplot2") -mpgman2 <- mpg \%>\% - group_by(manufacturer, year) \%>\% +mpgman2 <- mpg |> + group_by(manufacturer, year) |> dplyr::summarise( n = dplyr::n(), - displ = mean(displ) - ) + displ = mean(displ), + .groups = "drop" + ) mpgman2 @@ -59,36 +60,35 @@ hchart( colorKey = "displ", # color = c("#FCA50A", "#FCFFA4"), name = c("Year 1999", "Year 2008") -) \%>\% + ) |> hc_colorAxis(min = 0, max = 5) # defaults to yAxis -hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) \%>\% +hchart(iris, "point", hcaes(Sepal.Length, Sepal.Width)) |> hc_colorAxis( minColor = "red", maxColor = "blue" ) - - # Ex2 n <- 5 stops <- data.frame( - q = 0:n / n, + q = 0:n/n, c = c("#440154", "#414487", "#2A788E", "#22A884", "#7AD151", "#FDE725"), stringsAsFactors = FALSE -) + ) stops <- list_parse2(stops) -M <- round(matrix(rnorm(50 * 50), ncol = 50), 2) +M <- round(matrix(rnorm(50*50), ncol = 50), 2) -hchart(M) \%>\% +hchart(M) |> hc_colorAxis(stops = stops) # Ex3 -# hchart(volcano) \%>\% -# hc_colorAxis(stops = stops, max = 200) +hchart(volcano) |> + hc_colorAxis(stops = stops, max = 200) + } diff --git a/man/hc_colors.Rd b/man/hc_colors.Rd index d4c6939a..2df4269b 100644 --- a/man/hc_colors.Rd +++ b/man/hc_colors.Rd @@ -22,9 +22,10 @@ library(viridisLite) cols <- viridis(3) cols <- substr(cols, 0, 7) -highchart() \%>\% - hc_add_series(data = sample(1:12)) \%>\% - hc_add_series(data = sample(1:12) + 10) \%>\% - hc_add_series(data = sample(1:12) + 20) \%>\% +highchart() |> + hc_add_series(data = sample(1:12)) |> + hc_add_series(data = sample(1:12) + 10) |> + hc_add_series(data = sample(1:12) + 20) |> hc_colors(cols) + } diff --git a/man/hc_credits.Rd b/man/hc_credits.Rd index 13c91e2d..0d66561a 100644 --- a/man/hc_credits.Rd +++ b/man/hc_credits.Rd @@ -17,12 +17,13 @@ of the chart. This can be changed using these options. } \examples{ -highchart() \%>\% - hc_xAxis(categories = citytemp$month) \%>\% - hc_add_series(name = "Tokyo", data = sample(1:12)) \%>\% +highchart() |> + hc_xAxis(categories = citytemp$month) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_credits( enabled = TRUE, text = "htmlwidgets.org", href = "http://www.htmlwidgets.org/" - ) + ) + } diff --git a/man/hc_drilldown.Rd b/man/hc_drilldown.Rd index 4a61267b..9d3d54ca 100644 --- a/man/hc_drilldown.Rd +++ b/man/hc_drilldown.Rd @@ -32,16 +32,16 @@ df <- tibble( df -hc <- highchart() \%>\% - hc_title(text = "Basic drilldown") \%>\% - hc_xAxis(type = "category") \%>\% - hc_legend(enabled = FALSE) \%>\% +hc <- highchart() |> + hc_title(text = "Basic drilldown") |> + hc_xAxis(type = "category") |> + hc_legend(enabled = FALSE) |> hc_plotOptions( series = list( boderWidth = 0, dataLabels = list(enabled = TRUE) ) - ) \%>\% + ) |> hc_add_series( data = df, type = "column", @@ -65,7 +65,7 @@ dsan <- list_parse2(dfan) dsfru <- list_parse2(dffru) -hc <- hc \%>\% +hc <- hc |> hc_drilldown( allowPointDrilldown = TRUE, series = list( @@ -81,4 +81,7 @@ hc <- hc \%>\% ) hc + + + } diff --git a/man/hc_exporting.Rd b/man/hc_exporting.Rd index cec6042f..6c4cf44a 100644 --- a/man/hc_exporting.Rd +++ b/man/hc_exporting.Rd @@ -17,11 +17,12 @@ the docs. } \examples{ -highchart() \%>\% - hc_xAxis(categories = month.abb) \%>\% - hc_add_series(name = "Tokyo", data = sample(1:12)) \%>\% +highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> hc_exporting( enabled = TRUE, # always enabled filename = "custom-file-name" - ) + ) + } diff --git a/man/hc_labels.Rd b/man/hc_labels.Rd index c3492ac7..c17c991d 100644 --- a/man/hc_labels.Rd +++ b/man/hc_labels.Rd @@ -18,12 +18,12 @@ annotations that support labels. } \examples{ -highchart() \%>\% - hc_add_series(data = sample(1:12)) \%>\% +highchart() |> + hc_add_series(data = sample(1:12)) |> hc_labels( items = list( list( - html = "

Some important
text

", + html = "

Some important
text

" , style = list( left = "150\%", top = "150\%" @@ -31,4 +31,6 @@ highchart() \%>\% ) ) ) + + } diff --git a/man/hc_legend.Rd b/man/hc_legend.Rd index 1eae2ce3..dde182a1 100644 --- a/man/hc_legend.Rd +++ b/man/hc_legend.Rd @@ -25,16 +25,17 @@ Either as a gradient, or as multiple legend items for dataClasses. } \examples{ -highchart() \%>\% - hc_xAxis(categories = month.abb) \%>\% - hc_add_series(name = "Tokyo", data = sample(1:12)) \%>\% - hc_add_series(name = "London", data = sample(1:12) + 10) \%>\% - hc_add_series(name = "Other City", data = sample(1:12) + 20) \%>\% +highchart() |> + hc_xAxis(categories = month.abb) |> + hc_add_series(name = "Tokyo", data = sample(1:12)) |> + hc_add_series(name = "London", data = sample(1:12) + 10) |> + hc_add_series(name = "Other City", data = sample(1:12) + 20) |> hc_legend( align = "left", verticalAlign = "top", layout = "vertical", x = 0, y = 100 - ) + ) + } diff --git a/man/hc_loading.Rd b/man/hc_loading.Rd index d99d91e6..9c0f7b57 100644 --- a/man/hc_loading.Rd +++ b/man/hc_loading.Rd @@ -22,9 +22,10 @@ object, but part of the lang object. } \examples{ -highcharts_demo() \%>\% +highcharts_demo() |> hc_loading( hideDuration = 1000, showDuration = 1000 ) + } diff --git a/man/hc_mapNavigation.Rd b/man/hc_mapNavigation.Rd index 4d03613e..74099de3 100644 --- a/man/hc_mapNavigation.Rd +++ b/man/hc_mapNavigation.Rd @@ -12,14 +12,16 @@ hc_mapNavigation(hc, ...) \item{...}{Arguments defined in \url{https://api.highcharts.com/highmaps/mapNavigation}.} } \description{ -Mapnavigation options for highcharter objects +The mapNavigation option handles buttons for navigation in addition to +mousewheel and doubleclick handlers for map zooming. } \examples{ -hcmap(download_map_data = TRUE) \%>\% +hcmap(download_map_data = FALSE) |> hc_mapNavigation( enabled = TRUE, enableMouseWheelZoom = TRUE, enableDoubleClickZoom = TRUE ) + } diff --git a/man/hc_mapView.Rd b/man/hc_mapView.Rd new file mode 100644 index 00000000..9c25b2c9 --- /dev/null +++ b/man/hc_mapView.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/highcharts-api.R +\name{hc_mapView} +\alias{hc_mapView} +\title{Mapview options for highcharter objects} +\usage{ +hc_mapView(hc, ...) +} +\arguments{ +\item{hc}{A \code{highchart} \code{htmlwidget} object.} + +\item{...}{Arguments defined in \url{https://api.highcharts.com/highmaps/mapView}.} +} +\description{ +The mapView options control the initial view of the chart, and how +projection is set up for raw geoJSON maps (beta as of v9.3). +To set the view dynamically after chart generation, see +mapView.setView. +} +\examples{ + +map <- hcmap() + +map + +map |> + hc_mapView(zoom = 10) |> + hc_mapNavigation(enabled = TRUE) + + + +} diff --git a/man/hc_navigator.Rd b/man/hc_navigator.Rd index 49742469..1d154aaf 100644 --- a/man/hc_navigator.Rd +++ b/man/hc_navigator.Rd @@ -18,9 +18,9 @@ out on parts of the data as well as panning across the dataset. } \examples{ -highchart(type = "stock") \%>\% - hc_add_series(AirPassengers) \%>\% - hc_rangeSelector(selected = 4) \%>\% +highchart(type = "stock") |> + hc_add_series(AirPassengers) |> + hc_rangeSelector(selected = 4) |> hc_navigator( outlineColor = "gray", outlineWidth = 2, @@ -35,4 +35,5 @@ highchart(type = "stock") \%>\% borderColor = "red" ) ) + } diff --git a/man/hc_pane.Rd b/man/hc_pane.Rd index 9afdb0cc..61937227 100644 --- a/man/hc_pane.Rd +++ b/man/hc_pane.Rd @@ -17,23 +17,23 @@ gauges and polar charts. } \examples{ -highchart() \%>\% +highchart() |> hc_chart( - type = "gauge", - plotBackgroundColor = NULL, - plotBackgroundImage = NULL, - plotBorderWidth = 0, - plotShadow = FALSE - ) \%>\% + type = "gauge", + plotBackgroundColor = NULL, + plotBackgroundImage = NULL, + plotBorderWidth = 0, + plotShadow = FALSE + ) |> hc_title( text = "Speedometer" - ) \%>\% + ) |> hc_pane( startAngle = -150, endAngle = 150, background = list(list( backgroundColor = list( - linearGradient = list(x1 = 0, y1 = 0, x2 = 0, y2 = 1), + linearGradient = list( x1 = 0, y1 = 0, x2 = 0, y2 = 1), stops = list( list(0, "#FFF"), list(1, "#333") @@ -43,7 +43,7 @@ highchart() \%>\% outerRadius = "109\%" ), list( backgroundColor = list( - linearGradient = list(x1 = 0, y1 = 0, x2 = 0, y2 = 1), + linearGradient = list( x1 = 0, y1 = 0, x2 = 0, y2 = 1), stops = list( list(0, "#333"), list(1, "#FFF") @@ -59,23 +59,28 @@ highchart() \%>\% outerRadius = "105\%", innerRadius = "103\%" )) - ) \%>\% + ) |> hc_add_series( data = list(80), name = "speed", tooltip = list(valueSuffix = " km/h") - ) \%>\% + ) |> + + hc_yAxis( min = 0, max = 200, + minorTickInterval = "auto", minorTickWidth = 1, minorTickLength = 10, minorTickPosition = "inside", minorTickColor = "#666", + tickPixelInterval = 30, tickWidth = 2, tickPosition = "inside", tickLength = 10, tickColor = "#666", + labels = list( step = 2, rotation = "auto" @@ -83,10 +88,14 @@ highchart() \%>\% title = list( text = "km/h" ), + plotBands = list( - list(from = 0, to = 120, color = "#55BF3B"), + list(from = 0, to = 120, color = "#55BF3B"), list(from = 120, to = 160, color = "#DDDF0D"), list(from = 160, to = 200, color = "#DF5353") ) + ) + + } diff --git a/man/hc_plotOptions.Rd b/man/hc_plotOptions.Rd index 87c4a9fc..9eb1dcae 100644 --- a/man/hc_plotOptions.Rd +++ b/man/hc_plotOptions.Rd @@ -23,10 +23,10 @@ the series array. } \examples{ -highchart() \%>\% +highchart() |> hc_add_series( data = c(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4) - ) \%>\% + ) |> hc_plotOptions( line = list( color = "blue", @@ -34,7 +34,8 @@ highchart() \%>\% fillColor = "white", lineWidth = 2, lineColor = NULL + ) ) ) - ) + } diff --git a/man/hc_rangeSelector.Rd b/man/hc_rangeSelector.Rd index 8ef2c0e1..45758457 100644 --- a/man/hc_rangeSelector.Rd +++ b/man/hc_rangeSelector.Rd @@ -19,17 +19,18 @@ boxes where min and max dates can be manually input. } \examples{ -hc <- highchart(type = "stock") \%>\% +hc <- highchart(type = "stock") |> hc_add_series(AirPassengers) hc -hc \%>\% +hc |> hc_rangeSelector(enabled = FALSE) -hc \%>\% +hc |> hc_rangeSelector( verticalAlign = "bottom", selected = 4 - ) + ) + } diff --git a/man/hc_responsive.Rd b/man/hc_responsive.Rd index 317b784b..3288e6b9 100644 --- a/man/hc_responsive.Rd +++ b/man/hc_responsive.Rd @@ -18,24 +18,25 @@ sizes. Each rule specifies additional chart options. \examples{ leg_500_opts <- list(enabled = FALSE) -leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "vertical") +leg_900_opts <- list(align = "right", verticalAlign = "middle", layout = "vertical") # change the with of the container/windows to see the effect -highchart() \%>\% - hc_add_series(data = cumsum(rnorm(100))) \%>\% +highchart() |> + hc_add_series(data = cumsum(rnorm(100))) |> hc_responsive( rules = list( # remove legend if there is no much space list( - condition = list(maxWidth = 500), + condition = list(maxWidth = 500), chartOptions = list(legend = leg_500_opts) ), # put legend on the right when there is much space list( - condition = list(minWidth = 900), + condition = list(minWidth = 900), chartOptions = list(legend = leg_900_opts) ) ) ) + } diff --git a/man/hc_scrollbar.Rd b/man/hc_scrollbar.Rd index bc7f549f..afb4d275 100644 --- a/man/hc_scrollbar.Rd +++ b/man/hc_scrollbar.Rd @@ -23,9 +23,9 @@ scrollbar are replaced by the classes .highcharts-scrollbar-thumb, } \examples{ -highchart(type = "stock") \%>\% - hc_add_series(AirPassengers) \%>\% - hc_rangeSelector(selected = 4) \%>\% +highchart(type = "stock") |> + hc_add_series(AirPassengers) |> + hc_rangeSelector(selected = 4) |> hc_scrollbar( barBackgroundColor = "gray", barBorderRadius = 7, @@ -40,4 +40,5 @@ highchart(type = "stock") \%>\% trackBorderColor = "silver", trackBorderRadius = 7 ) + } diff --git a/man/hc_series.Rd b/man/hc_series.Rd index cf879910..c012f24c 100644 --- a/man/hc_series.Rd +++ b/man/hc_series.Rd @@ -18,7 +18,7 @@ possible options for a series. } \examples{ -highchart() \%>\% +highchart() |> hc_series( list( name = "Tokyo", @@ -29,4 +29,5 @@ highchart() \%>\% data = c(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8) ) ) + } diff --git a/man/hc_subtitle.Rd b/man/hc_subtitle.Rd index 1bddea23..b005d38a 100644 --- a/man/hc_subtitle.Rd +++ b/man/hc_subtitle.Rd @@ -19,14 +19,15 @@ Chart.setTitle method. } \examples{ -highchart() \%>\% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "column" - ) \%>\% + ) |> hc_subtitle( text = "And this is a subtitle with more information", align = "left", style = list(color = "#2b908f", fontWeight = "bold") - ) + ) + } diff --git a/man/hc_title.Rd b/man/hc_title.Rd index 4fbaa0c7..b9a29faa 100644 --- a/man/hc_title.Rd +++ b/man/hc_title.Rd @@ -16,15 +16,16 @@ The chart's main title. } \examples{ -highchart() \%>\% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "column" - ) \%>\% + ) |> hc_title( text = "This is a title with margin and Strong or bold text", margin = 20, align = "left", style = list(color = "#22A884", useHTML = TRUE) - ) + ) + } diff --git a/man/hc_tooltip.Rd b/man/hc_tooltip.Rd index e5a58928..c8fb8256 100644 --- a/man/hc_tooltip.Rd +++ b/man/hc_tooltip.Rd @@ -12,10 +12,10 @@ hc_tooltip(hc, ..., sort = FALSE, table = FALSE) \item{...}{Arguments defined in \url{https://api.highcharts.com/highcharts/tooltip}.} \item{sort}{Logical value to implement sort according \code{this.point} -\url{https://stackoverflow.com/a/16954666/829971}.} +\url{http://stackoverflow.com/a/16954666/829971}.} \item{table}{Logical value to implement table in tooltip: -\url{https://stackoverflow.com/a/22327749/829971}.} +\url{http://stackoverflow.com/a/22327749/829971}.} } \description{ Options for the tooltip that appears when the user hovers over a @@ -23,13 +23,15 @@ series or point. } \examples{ -highchart() \%>\% - hc_add_series(data = sample(1:12)) \%>\% - hc_add_series(data = sample(1:12) + 10) \%>\% +highchart() |> + hc_add_series(data = sample(1:12)) |> + hc_add_series(data = sample(1:12) + 10) |> hc_tooltip( crosshairs = TRUE, borderWidth = 5, sort = TRUE, table = TRUE - ) + ) + + } diff --git a/man/hc_xAxis.Rd b/man/hc_xAxis.Rd index ec803e82..7eaab632 100644 --- a/man/hc_xAxis.Rd +++ b/man/hc_xAxis.Rd @@ -25,11 +25,11 @@ as setting the extremes of one of the exes. } \examples{ -highchart() \%>\% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "spline" - ) \%>\% + ) |> hc_xAxis( title = list(text = "x Axis at top"), alternateGridColor = "#FDFFD5", @@ -40,7 +40,8 @@ highchart() \%>\% color = "#FF0000", width = 2, value = 5.5 + ) ) ) - ) + } diff --git a/man/hc_yAxis.Rd b/man/hc_yAxis.Rd index bae14e02..87fc7963 100644 --- a/man/hc_yAxis.Rd +++ b/man/hc_yAxis.Rd @@ -21,11 +21,11 @@ access to the axis. } \examples{ -highchart() \%>\% +highchart() |> hc_add_series( data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6), type = "spline" - ) \%>\% + ) |> hc_yAxis( title = list(text = "y Axis at right"), opposite = TRUE, @@ -40,7 +40,8 @@ highchart() \%>\% to = 17, color = "rgba(100, 0, 0, 0.1)", label = list(text = "This is a plotBand") + ) ) - ) - ) + ) + } diff --git a/man/hc_zAxis.Rd b/man/hc_zAxis.Rd index beb316ee..3b126ddb 100644 --- a/man/hc_zAxis.Rd +++ b/man/hc_zAxis.Rd @@ -24,9 +24,8 @@ df <- data.frame( z = sample(1:5) ) -# Note the 3d requiere highchart2() due have the 3d module -highchart2() \%>\% - hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) \%>\% +highchart() |> + hc_add_series(data = df, "scatter3d", hcaes(x = x, y = y, z = z)) |> hc_chart( type = "scatter3d", options3d = list( @@ -42,7 +41,7 @@ highchart2() \%>\% ) ) ) - ) \%>\% + ) |> hc_zAxis( title = list(text = "Z axis is here"), startOnTick = FALSE, @@ -52,4 +51,5 @@ highchart2() \%>\% gridLineColor = "red", gridLineDashStyle = "dot" ) + }