Skip to content

Commit c7823e4

Browse files
committed
autogenerated marker.colorbar can be geo
1 parent f87e571 commit c7823e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

R/plotly_build.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,18 @@ map_color <- function(traces, title = "", na.color = "transparent") {
469469
showlegend = FALSE,
470470
marker = colorObj
471471
)
472-
if ("scatter3d" %in% unlist(lapply(traces, "[[", "type"))) {
472+
# yay for consistency plotly.js
473+
if ("scatter3d" %in% types) {
473474
colorBarTrace$type <- "scatter3d"
474475
colorBarTrace$z <- range(unlist(lapply(traces, "[[", "z")), na.rm = TRUE)
475476
}
477+
if (length(type <- intersect(c("scattergeo", "scattermapbox"), types))) {
478+
colorBarTrace$type <- type
479+
colorBarTrace$lat <- range(unlist(lapply(traces, "[[", "lat")), na.rm = TRUE)
480+
colorBarTrace$lon <- range(unlist(lapply(traces, "[[", "lon")), na.rm = TRUE)
481+
colorBarTrace[["x"]] <- NULL
482+
colorBarTrace[["y"]] <- NULL
483+
}
476484
traces[[length(traces) + 1]] <- structure(colorBarTrace, class = "plotly_colorbar")
477485
}
478486

0 commit comments

Comments
 (0)