From fbcf3919f71de515258b25381951ccf41343c0ba Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 7 Mar 2019 18:12:33 -0600 Subject: [PATCH 1/3] don't supply axis domain defaults if layout.grid is specified, fixes #1427 --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 3d39576bd7..6b573eb95b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -348,7 +348,7 @@ supply_defaults <- function(p) { p$x$layout[[p$x$layout$mapType]] <- modify_list( list(domain = geoDomain), p$x$layout[[p$x$layout$mapType]] ) - } else { + } else if (!length(p$x$layout[["grid"]])) { types <- vapply(p$x$data, function(tr) tr[["type"]] %||% "scatter", character(1)) axes <- unlist(lapply(types, function(x) { grep("^[a-z]axis$", names(Schema$traces[[x]]$attributes), value = TRUE) %||% NULL From 970e9fdfe6cf3cf139ee8eeea951aca93aa5c4c5 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 7 Mar 2019 18:32:02 -0600 Subject: [PATCH 2/3] add a test --- tests/testthat/test-plotly.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index 803c18284d..dcbf77bfe3 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -280,3 +280,18 @@ test_that("Can map data to legendgroup", { expect_true(bars[[i]]$legendgroup == letters[[i]]) } }) + + +test_that("Axis domains aren't supplied if layout.grid exists", { + p <- plot_ly(type = 'scatter',mode = 'lines', y = c(5,1,3), xaxis = 'x', yaxis = 'y') %>% + add_trace(y = c(2,1,5), xaxis = 'x2', yaxis = 'y2') %>% + add_trace(y = c(2,1,5), xaxis = 'x3', yaxis = 'y3')%>% + add_trace(y = c(2,1,5), xaxis = 'x4', yaxis = 'y4')%>% + add_trace(y = c(2,1,5), xaxis = 'x5', yaxis = 'y5')%>% + add_trace(y = c(2,1,5), xaxis = 'x6', yaxis = 'y6')%>% + layout(grid = list(rows = 2, columns = 3, pattern ='independent')) + + l <- expect_doppelganger_built(p, "layout-grid") + expect_null(l$layout$xaxis$domain) + expect_null(l$layout$yaxis$domain) +}) From 8f794c99cbfbb954807460b2b1653d4c57ca4591 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 7 Mar 2019 20:33:18 -0600 Subject: [PATCH 3/3] validate new baselines --- tests/figs/plotly/errorbar-width.svg | 1 + tests/figs/plotly/layout-grid.svg | 1 + tests/figs/size/marker-size.svg | 1 + tests/figs/size/sizemode.svg | 1 + tests/figs/subplot/plotly-subplot-shareboth.svg | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/figs/plotly/errorbar-width.svg create mode 100644 tests/figs/plotly/layout-grid.svg create mode 100644 tests/figs/size/marker-size.svg create mode 100644 tests/figs/size/sizemode.svg diff --git a/tests/figs/plotly/errorbar-width.svg b/tests/figs/plotly/errorbar-width.svg new file mode 100644 index 0000000000..350b49d1fa --- /dev/null +++ b/tests/figs/plotly/errorbar-width.svg @@ -0,0 +1 @@ +246810246810 diff --git a/tests/figs/plotly/layout-grid.svg b/tests/figs/plotly/layout-grid.svg new file mode 100644 index 0000000000..22684dbebb --- /dev/null +++ b/tests/figs/plotly/layout-grid.svg @@ -0,0 +1 @@ +00.511.521234500.511.521234500.511.521234500.511.521234500.511.521234500.511.5212345trace 0trace 1trace 2trace 3trace 4trace 5 diff --git a/tests/figs/size/marker-size.svg b/tests/figs/size/marker-size.svg new file mode 100644 index 0000000000..f94c4e025a --- /dev/null +++ b/tests/figs/size/marker-size.svg @@ -0,0 +1 @@ +246810246810 diff --git a/tests/figs/size/sizemode.svg b/tests/figs/size/sizemode.svg new file mode 100644 index 0000000000..86f61e2bb5 --- /dev/null +++ b/tests/figs/size/sizemode.svg @@ -0,0 +1 @@ +23451.522.533.544.555.5123468wtwt diff --git a/tests/figs/subplot/plotly-subplot-shareboth.svg b/tests/figs/subplot/plotly-subplot-shareboth.svg index e2d7d2e59e..ac0bc8f7f2 100644 --- a/tests/figs/subplot/plotly-subplot-shareboth.svg +++ b/tests/figs/subplot/plotly-subplot-shareboth.svg @@ -1 +1 @@ -00.20.40.60.810.511.500.20.40.60.810.511.5trace 0trace 1trace 2trace 3 +00.20.40.60.810.511.500.20.40.60.810.511.5trace 0trace 1trace 2trace 3