Skip to content

Commit 382cffa

Browse files
committed
Merge branch 'master' of https://github.com/ropensci/plotly into fix/build
2 parents 0d2c2fb + c36a44c commit 382cffa

File tree

11 files changed

+93
-40
lines changed

11 files changed

+93
-40
lines changed

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing to plotly.js
2+
3+
## Opening issues
4+
5+
Search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/ropensci/plotly/issues/new)
6+
7+
Bug reports __must__ have a [reproducible example](http://adv-r.had.co.nz/Reproducibility.html) and include the output of `devtools::session_info()` (instead of `sessionInfo()`).
8+
9+
GitHub issues are great for reporting bugs and requesting new features, but implementation questions are better suited for Stack Overflow (tagged
10+
[`plotly`](https://stackoverflow.com/questions/tagged/plotly)) or on
11+
community.plot.ly (tagged [`plotly-js`](http://community.plot.ly/c/plotly-js)).
12+
13+
## Development guidelines
14+
15+
If you'd like to contribute changes to plotly, we use [the GitHub flow](https://guides.github.com/introduction/flow/index.html) for proposing, submitting, reviewing, and accepting changes. If you haven't done this before, Hadley Wickham provides a nice overview of git (<http://r-pkgs.had.co.nz/git.html>), as well as best practices for submitting pull requests (<http://r-pkgs.had.co.nz/git.html#pr-make>). We also recommend using his style guide when writing code (<http://adv-r.had.co.nz/Style.html>).
16+
17+
If your pull request fixes a bug, or implements a new feature, it's a good idea to write a test (<http://r-pkgs.had.co.nz/tests.html>) to demonstrate it's working. If you'd like to closely simulate the tests that run when you submit your pull request, open R under your local plotly git repo, then do the following:
18+
19+
```r
20+
# the pull request number is arbitrary when running locally
21+
Sys.setenv('TRAVIS_PULL_REQUEST' = '1')
22+
Sys.setenv('TRAVIS_COMMIT' = substr(system('git rev-parse HEAD', intern = T), 1, 7))
23+
devtools::load_all(); source('tests/testthat.R', chdir = TRUE)
24+
```
25+
26+
You can also build a ggplot2/plotly comparison table:
27+
28+
```r
29+
Sys.setenv('PLOTLY_TEST' = 'TRUE')
30+
devtools::load_all(); source('tests/testthat.R', chdir = TRUE)
31+
```
32+
33+
## Code of Conduct
34+
35+
We want to encourage a warm, welcoming, and safe environment for contributing to this project. See the [code of conduct](https://github.com/ropensci/plotly/blob/master/CONDUCT.md) for more information.

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via Plotly's JavaScript Graphing Library
3-
Version: 2.0.18
3+
Version: 2.0.19
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ S3method(print,figure)
44
S3method(print,plotly)
55
export("%>%")
66
export(add_trace)
7+
export(as.widget)
78
export(config)
89
export(embed_notebook)
910
export(get_figure)

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.0.19 -- 23 Dec 2015
2+
3+
Added as.widget() function for conveniency in converting plotly object to htmlwidget objects. See #294.
4+
15
2.0.18 -- 22 Dec 2015
26

37
Fix #365

R/print.R

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
#' Print a plotly object
22
#'
33
#' @param x a plotly object
4-
#' @param ... additional arguments (currently ignored)
4+
#' @param ... additional arguments
55
#' @export
66
#' @importFrom htmlwidgets createWidget
77
#' @importFrom htmlwidgets sizingPolicy
88
print.plotly <- function(x, ...) {
9-
w <- toWidget(x)
10-
get("print.htmlwidget", envir = asNamespace("htmlwidgets"))(w)
9+
if (!inherits(x, "htmlwidget")) x <- as.widget(x)
10+
get("print.htmlwidget", envir = asNamespace("htmlwidgets"))(x, ...)
1111
}
1212

1313
#' Print a plotly object in a knitr doc
1414
#'
1515
#' @param x a plotly object
1616
#' @param options knitr options.
17-
#' @param ... additional arguments (currently ignored)
17+
#' @param ... additional arguments
1818
#' @export
1919
knit_print.plotly <- function(x, options, ...) {
20-
w <- toWidget(x)
21-
get("knit_print.htmlwidget", envir = asNamespace("htmlwidgets"))(w, options = options)
20+
if (!inherits(x, "htmlwidget")) x <- as.widget(x)
21+
get("knit_print.htmlwidget", envir = asNamespace("htmlwidgets"))(x, options = options, ...)
2222
}
2323

2424
#' Convert a plotly object to an htmlwidget object
2525
#'
26-
#' Users shouldn't need to use this function. It's exported for internal reasons.
27-
#'
2826
#' @param x a plotly object.
27+
#' @param ... other options passed onto \code{htmlwidgets::createWidget}
28+
#' @export
29+
#' @examples \dontrun{
30+
#' p <- plot_ly(mtcars, x = mpg, y = disp, mode = "markers")
31+
#' htmlwidgets::saveWidget(as.widget(p), "index.html")
32+
#' }
2933
#'
30-
toWidget <- function(x) {
34+
as.widget <- function(x, ...) {
3135
p <- plotly_build(x)
3236
# set some margin defaults if none are provided
3337
p$layout$margin <- modifyList(
@@ -41,13 +45,17 @@ toWidget <- function(x) {
4145
x = p,
4246
width = p$width,
4347
height = p$height,
44-
htmlwidgets::sizingPolicy(
48+
sizingPolicy = htmlwidgets::sizingPolicy(
4549
padding = 5,
4650
browser.fill = TRUE
47-
)
51+
),
52+
...
4853
)
4954
}
5055

56+
# for legacy reasons
57+
toWidget <- as.widget
58+
5159
#' Print a plotly figure object
5260
#'
5361
#' @param x a plotly figure object

R/shiny.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px") {
2626
renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) {
2727
if (!quoted) { expr <- substitute(expr) } # force quoted
2828
# https://github.com/ramnathv/htmlwidgets/issues/166#issuecomment-153000306
29-
expr <- as.call(list(call(":::", quote("plotly"), quote("toWidget")), expr))
29+
expr <- call("as.widget", expr)
3030
shinyRenderWidget(expr, plotlyOutput, env, quoted = TRUE)
3131
}

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ devtools::install_github("ropensci/plotly")
2020

2121
## Introduction
2222

23-
If you use [ggplot2](http://cran.r-project.org/package=ggplot2), simply call `ggplotly()` to convert your ggplot to an interactive, web-based version!
23+
If you use [ggplot2](http://cran.r-project.org/package=ggplot2), use `ggplotly()` to convert your ggplot to an interactive, web-based version!
2424

2525
```r
2626
library(plotly)
@@ -50,19 +50,15 @@ The `ggplotly()` function converts a ggplot object to a plotly object, so if you
5050
layout(gg, hovermode = "closest")
5151
```
5252

53-
## Learn more
53+
## Documentation
5454

55-
* [An overview of plotly's R API](https://cdn.rawgit.com/ropensci/plotly/master/vignettes/intro.html)
56-
* Peruse the examples on plotly's [R homepage](https://plot.ly/r) and [ggplot2 homepage](https://plot.ly/ggplot2)
55+
* [An introduction to plotly's R API](https://cran.r-project.org/web/packages/plotly/vignettes/intro.html)
56+
* Examples and vignettes on plotly's R homepage - <https://plot.ly/r>
57+
* The complete figure reference guide - <https://plot.ly/r/reference>
5758

5859
## Contributing
5960

60-
- We love collaboration! See the [wiki](https://github.com/ropensci/plotly/wiki/Development-guidelines) and the [code of conduct](https://github.com/ropensci/plotly/blob/master/CONDUCT.md) for more information.
61-
62-
## Stay in touch
63-
64-
65-
- [@plotlygraphs](https://twitter.com/plotlygraphs)
61+
Please read through our [contributing guidelines](https://github.com/ropensci/plotly/blob/master/CONTRIBUTING.md). Included are directions for opening issues, asking questions, contributing changes to plotly, and our code of conduct.
6662

6763
---
6864

man/as.widget.Rd

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

man/knit_print.plotly.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.plotly.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/toWidget.Rd

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)