Skip to content

Commit 000d78d

Browse files
committed
ignore data arrays of non-tidy traces. Fixes #737
1 parent c4147af commit 000d78d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

R/plotly_build.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ plotly_build.plotly <- function(p) {
146146
isArray <- lapply(Attrs, function(x) {
147147
tryCatch(identical(x[["valType"]], "data_array"), error = function(e) FALSE)
148148
})
149-
# I don't think we ever want mesh3d's data attrs
150-
dataArrayAttrs <- if (identical(trace[["type"]], "mesh3d")) NULL else names(Attrs)[as.logical(isArray)]
149+
# "non-tidy" traces allow x/y of different lengths, so ignore those
150+
dataArrayAttrs <- if (is_tidy(trace)) names(Attrs)[as.logical(isArray)]
151151
allAttrs <- c(
152152
dataArrayAttrs, special_attrs(trace), npscales(),
153153
# for some reason, text isn't listed as a data array in some traces

R/utils.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ getLevels <- function(x) {
4747
if (is.factor(x)) levels(x) else sort(unique(x))
4848
}
4949

50+
# Don't attempt to do "tidy" data training on these trace types
51+
is_tidy <- function(trace) {
52+
type <- trace[["type"]] %||% "scatter"
53+
!type %in% c(
54+
"mesh3d", "heatmap", "histogram2d",
55+
"histogram2dcontour", "contour", "surface"
56+
)
57+
}
58+
5059
# is grouping relevant for this geometry? (e.g., grouping doesn't effect a scatterplot)
5160
has_group <- function(trace) {
5261
inherits(trace, paste0("plotly_", c("segment", "path", "line", "polygon"))) ||

0 commit comments

Comments
 (0)