Skip to content

Commit 3b365c4

Browse files
committed
avoid hand-coding exceptions when searching for axis keys in supply defaults, closes #1261
1 parent 6642ba2 commit 3b365c4

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

R/utils.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,10 @@ supply_defaults <- function(p) {
349349
list(domain = geoDomain), p$x$layout[[p$x$layout$mapType]]
350350
)
351351
} else {
352-
axes <- if (is_type(p, "scatterternary")) {
353-
c("aaxis", "baxis", "caxis")
354-
} else if (is_type(p, "pie") || is_type(p, "parcoords") || is_type(p, "sankey") || is_type(p, "table")) {
355-
NULL
356-
} else {
357-
c("xaxis", "yaxis")
358-
}
352+
types <- vapply(p$x$data, function(tr) tr[["type"]] %||% "scatter", character(1))
353+
axes <- unlist(lapply(types, function(x) {
354+
grep("^[a-z]axis$", names(Schema$traces[[x]]$attributes), value = TRUE) %||% NULL
355+
}))
359356
for (axis in axes) {
360357
p$x$layout[[axis]] <- modify_list(
361358
list(domain = c(0, 1), automargin = TRUE), p$x$layout[[axis]]

0 commit comments

Comments
 (0)