Skip to content

Commit 92c1672

Browse files
committed
do a better job of labeling default values; fixes #1196
1 parent c066ffd commit 92c1672

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

R/helpers.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ colorbar_built <- function(p, ..., limits = NULL, which = 1) {
6363
# since the colorscale is in a different trace, retrain all traces
6464
p$x$data <- lapply(p$x$data, function(x) {
6565
col <- x$marker[["color"]]
66-
x$marker[["color"]][col < limits[1] | limits[2] < col] <- NA
67-
x$marker[["cmin"]] <- limits[1]
68-
x$marker[["cmax"]] <- limits[2]
66+
x$marker[["color"]][col < limits[1] | limits[2] < col] <- default(NA)
67+
x$marker[["cmin"]] <- default(limits[1])
68+
x$marker[["cmax"]] <- default(limits[2])
6969
x
7070
})
7171
}
@@ -110,10 +110,10 @@ hide_colorbar <- function(p) {
110110
for (i in seq_along(p$x$data)) {
111111
trace <- p$x$data[[i]]
112112
if (has_attr(trace$type, "showscale")) {
113-
p$x$data[[i]]$showscale <- FALSE
113+
p$x$data[[i]]$showscale <- default(FALSE)
114114
}
115115
if (has_attr(trace$type, "marker")) {
116-
p$x$data[[i]]$marker$showscale <- FALSE
116+
p$x$data[[i]]$marker$showscale <- default(FALSE)
117117
}
118118
}
119119
p

R/plotly_build.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ map_color <- function(traces, stroke = FALSE, title = "", colorway, na.color = "
852852

853853
# add an "empty" trace with the colorbar
854854
colorObj$color <- rng
855-
colorObj$showscale <- TRUE
855+
colorObj$showscale <- default(TRUE)
856856
colorBarTrace <- list(
857857
x = range(unlist(lapply(traces, "[[", "x")), na.rm = TRUE),
858858
y = range(unlist(lapply(traces, "[[", "y")), na.rm = TRUE),

0 commit comments

Comments
 (0)