Skip to content

Commit cf4b435

Browse files
committed
Close #2040, add_area() now uses barpolar instead of area which was dropped in 2.0 release
1 parent 1889ca6 commit cf4b435

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Breaking changes in JavaScript API
44

5-
* This version of the R package upgrades the version of the underlying plotly.js library from v1.57.1 to v2.5.1. This includes many breaking changes, bug fixes, and improvements to the underlying JavaScript library. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes.
5+
* This version of the R package upgrades the version of the underlying plotly.js library from v1.57.1 to v2.5.1. This includes many breaking changes, bug fixes, and improvements to the underlying JavaScript library. Most of the breaking changes are summarized in [this announcement of the 2.0 release](https://community.plotly.com/t/announcing-plotly-js-2-0/53675), but [see here](https://github.com/plotly/plotly.js/blob/HEAD/CHANGELOG.md) for the full changelog.
66

77
## Breaking changes in R API
88

R/add.R

+17-8
Original file line numberDiff line numberDiff line change
@@ -432,20 +432,29 @@ add_image <- function(p, z = NULL, colormodel = NULL, ..., data = NULL, inherit
432432

433433
#' @inheritParams add_trace
434434
#' @rdname add_trace
435-
#' @param r For polar chart only. Sets the radial coordinates.
436-
#' @param t For polar chart only. Sets the radial coordinates.
435+
#' @param r Sets the radial coordinates.
436+
#' @param theta Sets the angular coordinates.
437+
#' @param t Deprecated. Use `theta` instead.
437438
#' @export
438-
add_area <- function(p, r = NULL, t = NULL, ...,
439+
add_area <- function(p, r = NULL, theta = NULL, t = NULL, ...,
439440
data = NULL, inherit = TRUE) {
441+
if (!is.null(t)) {
442+
message(
443+
"Since `add_area()` now uses the barpolar instead of the area trace, ",
444+
"the `t` argument is now deprecated. Use the `theta` argument instead."
445+
)
446+
}
447+
theta <- theta %||% t
440448
if (inherit) {
441-
r <- t %||% p$x$attrs[[1]][["r"]]
442-
t <- t %||% p$x$attrs[[1]][["t"]]
449+
attrs <- p$x$attrs[[1]]
450+
r <- t %||% attrs[["r"]]
451+
theta <- theta %||% (attrs[["theta"]] %||% attrs[["t"]])
443452
}
444-
if (is.null(r) || is.null(t)) {
445-
stop("Must supply `r`/`t` attributes", call. = FALSE)
453+
if (is.null(r) || is.null(theta)) {
454+
stop("Must supply `r`/`theta` attributes", call. = FALSE)
446455
}
447456
add_trace_classed(
448-
p, class = "plotly_area", r = r, t = t, type = "area",
457+
p, class = "plotly_area", r = r, theta = theta, type = "barpolar",
449458
..., data = data, inherit = inherit
450459
)
451460
}

man/add_trace.Rd

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-plotly-area.R

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test_that("add_area() works", {
2+
data(wind)
3+
p <- plot_ly(wind, r = ~r, t = ~t) %>%
4+
add_area(color = ~nms) %>%
5+
layout(radialaxis = list(ticksuffix = "%"), orientation = 270)
6+
expect_doppelganger_built(p, "add-area")
7+
})

0 commit comments

Comments
 (0)