Skip to content

Commit b188a70

Browse files
committed
forgot supply_defaults specifically designed for non-subplots
1 parent 18b4079 commit b188a70

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

R/utils.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ is_subplot <- function(p) {
132132
}
133133

134134
supply_defaults <- function(p) {
135+
# no need to supply defaults for subplots
136+
if (is_subplot(p)) return(p)
135137
# supply trace anchor defaults
136138
anchors <- if (is_geo(p)) c("geo" = "geo") else if (is_mapbox(p)) c("subplot" = "mapbox") else c("xaxis" = "x", "yaxis" = "y")
137139

@@ -207,6 +209,9 @@ verify_boxed <- function(p) {
207209
thisTrace <- p$x$data[[tr]]
208210
validAttrs <- Schema$traces[[thisTrace$type %||% "scatter"]]$attributes
209211
p$x$data[[tr]] <- verify_box(thisTrace, validAttrs)
212+
# prevent these objects from sending null keys
213+
p$x$data[[tr]][["xaxis"]] <- p$x$data[[tr]][["xaxis"]] %||% NULL
214+
p$x$data[[tr]][["yaxis"]] <- p$x$data[[tr]][["yaxis"]] %||% NULL
210215
}
211216
p$x$layout$updatemenus
212217

tests/testthat/test-plotly-subplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ s <- subplot(
8686
)
8787

8888
test_that("Row/column height/width", {
89-
l <- expect_traces(s, 3, "width-height")
89+
l <- expect_traces(s, 4, "width-height")
9090
expect_equal(diff(l$layout$xaxis$domain), 0.8 - 0.005)
9191
expect_equal(diff(l$layout$xaxis2$domain), 0.2 - 0.005)
9292
expect_equal(diff(l$layout$yaxis$domain), 0.2 - 0.005)

0 commit comments

Comments
 (0)