Skip to content

Commit 181176d

Browse files
committed
Pass plot configuration using ... to avoid conflicts in defaults/documentation
1 parent f6093bb commit 181176d

File tree

2 files changed

+15
-69
lines changed

2 files changed

+15
-69
lines changed

R/plotly.R

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -178,46 +178,16 @@ layout <- function(p = last_plot(), ...,
178178
#' Set the default configuration for plotly
179179
#'
180180
#' @param p a plotly object
181-
#' @param staticPlot for export or image generation
182-
#' @param workspace we're in the workspace, so need toolbar etc (TODO describe functionality instead)?
183-
#' @param editable edit titles, move annotations, etc
184-
#' @param autosizable respect layout.autosize=true and infer its container size?
185-
#' @param fillFrame if we DO autosize, do we fill the container or the screen?
186-
#' @param scrollZoom mousewheel or two-finger scroll zooms the plot
187-
#' @param doubleClick double click interaction (false, 'reset', 'autosize' or 'reset+autosize')
188-
#' @param showTips see some hints about interactivity
189-
#' @param showLink link to open this plot in plotly
190-
#' @param sendData if we show a link, does it contain data or just link to a plotly file?
191-
#' @param linkText text appearing in the sendData link
192-
#' @param displayModeBar display the modebar (T, F, or 'hover')
193-
#' @param displaylogo add the plotly logo on the end of the modebar
194-
#' @param plot3dPixelRatio increase the pixel ratio for 3D plot images
181+
#' @param ... these arguments are documented at
182+
#' \url{https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js}
195183
#' @author Carson Sievert
196184
#' @export
185+
#' @examples \dontrun{
186+
#' config(plot_ly(), displaylogo = FALSE, modeBarButtonsToRemove = list('sendDataToCloud'))
187+
#' }
197188

198-
# TODO: use htmlwidgets::JS() to specify setBackground function?
199-
# https://github.com/ropensci/plotly/issues/284#issue-108153160
200-
config <- function(p = last_plot(), staticPlot = F, workspace = F, editable = F,
201-
autosizable = F, fillFrame = F, scrollZoom = F,
202-
doubleClick = 'reset+autosize', showTips = F, showLink = T,
203-
sendData = T, linkText = 'Edit chart', displayModeBar = 'hover',
204-
displaylogo = T, plot3dPixelRatio = 2) {
205-
conf <- list(
206-
staticPlot = staticPlot,
207-
workspace = workspace,
208-
editable = editable,
209-
autosizable = autosizable,
210-
fillFrame = fillFrame,
211-
scrollZoom = scrollZoom,
212-
doubleClick = doubleClick,
213-
showTips = showTips,
214-
showLink = showLink,
215-
sendData = sendData,
216-
linkText = linkText,
217-
displayModeBar = displayModeBar,
218-
displaylogo = displaylogo,
219-
plot3dPixelRatio = plot3dPixelRatio
220-
)
189+
config <- function(p = last_plot(), ...) {
190+
conf <- list(...)
221191
p <- last_plot(p)
222192
p$config <- c(p$config, conf)
223193
hash_plot(if (is.data.frame(p)) p else list(), p)

man/config.Rd

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

0 commit comments

Comments
 (0)