Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass plot configuration using ... to avoid conflicts in defaults/documentation #446

Merged
merged 3 commits into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: plotly
Title: Create Interactive Web Graphics via Plotly's JavaScript Graphing Library
Version: 2.3.4
Version: 2.4.0
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
email = "cpsievert1@gmail.com"),
person("Chris", "Parmer", role = c("aut", "cph"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.4.0 -- 1 Feb 2015

* Pass plot configuration using ... to avoid conflicts in defaults/documentation
* Upgrade to plotly.js 1.5.1

2.3.4 -- 1 Feb 2015

Added a plotly_api_domain environment variable for configuring the API domain. Fixes #441
Expand Down
44 changes: 7 additions & 37 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,46 +178,16 @@ layout <- function(p = last_plot(), ...,
#' Set the default configuration for plotly
#'
#' @param p a plotly object
#' @param staticPlot for export or image generation
#' @param workspace we're in the workspace, so need toolbar etc (TODO describe functionality instead)?
#' @param editable edit titles, move annotations, etc
#' @param autosizable respect layout.autosize=true and infer its container size?
#' @param fillFrame if we DO autosize, do we fill the container or the screen?
#' @param scrollZoom mousewheel or two-finger scroll zooms the plot
#' @param doubleClick double click interaction (false, 'reset', 'autosize' or 'reset+autosize')
#' @param showTips see some hints about interactivity
#' @param showLink link to open this plot in plotly
#' @param sendData if we show a link, does it contain data or just link to a plotly file?
#' @param linkText text appearing in the sendData link
#' @param displayModeBar display the modebar (T, F, or 'hover')
#' @param displaylogo add the plotly logo on the end of the modebar
#' @param plot3dPixelRatio increase the pixel ratio for 3D plot images
#' @param ... these arguments are documented at
#' \url{https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js}
#' @author Carson Sievert
#' @export
#' @examples \dontrun{
#' config(plot_ly(), displaylogo = FALSE, modeBarButtonsToRemove = list('sendDataToCloud'))
#' }

# TODO: use htmlwidgets::JS() to specify setBackground function?
# https://github.com/ropensci/plotly/issues/284#issue-108153160
config <- function(p = last_plot(), staticPlot = F, workspace = F, editable = F,
autosizable = F, fillFrame = F, scrollZoom = F,
doubleClick = 'reset+autosize', showTips = F, showLink = T,
sendData = T, linkText = 'Edit chart', displayModeBar = 'hover',
displaylogo = T, plot3dPixelRatio = 2) {
conf <- list(
staticPlot = staticPlot,
workspace = workspace,
editable = editable,
autosizable = autosizable,
fillFrame = fillFrame,
scrollZoom = scrollZoom,
doubleClick = doubleClick,
showTips = showTips,
showLink = showLink,
sendData = sendData,
linkText = linkText,
displayModeBar = displayModeBar,
displaylogo = displaylogo,
plot3dPixelRatio = plot3dPixelRatio
)
config <- function(p = last_plot(), ...) {
conf <- list(...)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done 🎉

p <- last_plot(p)
p$config <- c(p$config, conf)
hash_plot(if (is.data.frame(p)) p else list(), p)
Expand Down
76 changes: 37 additions & 39 deletions inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/htmlwidgets/plotly.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies:
- name: plotlyjs
version: 1.4.1
version: 1.5.1
src: "htmlwidgets/lib/plotlyjs"
script: plotly-latest.min.js
40 changes: 8 additions & 32 deletions man/config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.