Skip to content

Commit 780f968

Browse files
committed
Add fill argument to plotlyOutput()
1 parent 059786f commit 780f968

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

NEWS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* `highlight()` now supports `on="plotly_selecting"`, enabling client-side linked brushing via mouse click+drag (no mouse-up event required, as with `on="plotly_selected"`). (#1280)
1111
* `raster2uri()` supports nativeRaster objects. This enables nativeRaster support for
1212
the `annotation_raster()` geom (#2174, @zeehio).
13+
* `plotlyOutput()`'s gains a `fill` argument which , allowing it have more flexible default sizing behavior, which will be useful in combination with `{bslib}`'s new `card()`. (#2192)
14+
15+
* `plotlyOutput()` gains a new `fill` parameter. When `TRUE` (the default), the widget's container element is allowed to grow/shrink to fit it's parent container so long as that parent is opinionated about its height and has been marked with `htmltools::bindFillRole(x, container = TRUE)`. (#)
16+
* The primary motivation for this is to allow plots to grow/shrink by default [inside `bslib::card_body_fill()`](https://rstudio.github.io/bslib/articles/cards.html#responsive-sizing)
1317

1418
## Bug fixes
1519

@@ -22,7 +26,6 @@
2226

2327
## Improvements
2428

25-
* `plotlyOutput()`'s `height` and `width` now defaults to `NULL`, allowing it have more flexible default sizing behavior, which will be useful in combination with `{bslib}`'s new `card()`. (#2192)
2629
* `ggplotly()` does not issue warnings with `options(warnPartialMatchArgs = TRUE)` any longer. (#2046, thanks @bersbersbers)
2730
* `ggplotly()` does not issue warnings related to use of deprecated `tidyr::gather_()` in internals. (#2125, thanks @simonpcouch)
2831

R/shiny.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
#' @param env The environment in which to evaluate `expr`.
1818
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
1919
#' is useful if you want to save an expression in a variable.
20-
#'
20+
#' @param fill see [htmlwidgets::shinyWidgetOutput()] for explanation (requires
21+
#' a recent version of htmlwidgets).
2122
#' @importFrom htmlwidgets shinyWidgetOutput
2223
#' @importFrom htmlwidgets shinyRenderWidget
2324
#' @name plotly-shiny
2425
#'
2526
#' @export
2627
plotlyOutput <- function(outputId, width = "100%", height = "400px",
27-
inline = FALSE, reportTheme = TRUE) {
28+
inline = FALSE, reportTheme = TRUE, fill = !inline) {
2829
args <- list(
2930
outputId = outputId,
3031
name = "plotly",
@@ -37,6 +38,9 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px",
3738
if (is_installed("shiny", "1.4.0.9003") && is_installed("htmlwidgets", "1.5.2.9000")) {
3839
args$reportTheme <- reportTheme
3940
}
41+
if (is_installed("htmlwidgets", "1.5.4.9001")) {
42+
args$fill <- fill
43+
}
4044
do.call(htmlwidgets::shinyWidgetOutput, args)
4145
}
4246

man/plotly-shiny.Rd

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)