Skip to content

Commit 561871d

Browse files
committed
add argument to view source files in plotly_example(), relay ... to demo(), update news
1 parent c465935 commit 561871d

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ Suggests:
7171
plotlyGeoAssets,
7272
forcats
7373
LazyData: true
74-
RoxygenNote: 6.1.0
74+
RoxygenNote: 6.1.1
7575
Encoding: UTF-8
7676
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* The `orca()` function now supports conversion of much larger figures (#1322) and works without a mapbox api token (#1314).
1212
* The `style()` function now supports "partial updates" (i.e. modification of a particular property of an object, rather than the entire object). For example, notice how the first plot retains the original marker shape (a square): `p <- plot_ly(x = 1:10, y = 1:10, symbol = I(15)); subplot(style(p, marker.color = "red"), style(p, marker = list(color = "red")))` (#1342).
1313
* **plotly** objects can now be serialized and unserialized in different environments (i.e., you can now use `saveRDS()` to save an object as an rds file and restore it on another machine with `readRDS()`). Note this object is *dynamically* linked to JavaScript libraries, so one should take care to use consistent versions of **plotly** when serializing and unserializing (#1376).
14+
* The `plotly_example()` will now attempt to open the source file(s) used to run the example. Set `edit = FALSE` to prevent the source file(s) from opening.
1415

1516
## BUG FIXES
1617

R/plotly_example.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
#'
66
#' @param type the type of example
77
#' @param name the name of the example (valid names depend on `type`).
8+
#' @param edit whether to open the relevant source files using [file.edit]. Only relevant if `type` is `"shiny"` or `"rmd"`.
89
#' @param ... arguments passed onto the suitable method.
910
#' @export
1011
#' @author Carson Sievert
1112

12-
plotly_example <- function(type = c("demo", "shiny", "rmd"), name, ...) {
13+
plotly_example <- function(type = c("demo", "shiny", "rmd"), name, edit = TRUE, ...) {
1314

1415
type <- match.arg(type)
1516

1617
# demos don't necessarily need a name
1718
if (type == "demo") {
1819
if (missing(name)) {
19-
return(utils::demo(package = "plotly"))
20+
return(utils::demo(package = "plotly", ...))
2021
} else {
21-
return(utils::demo(topic = name, package = "plotly"))
22+
return(utils::demo(topic = name, package = "plotly", ...))
2223
}
2324
}
2425

@@ -36,6 +37,11 @@ plotly_example <- function(type = c("demo", "shiny", "rmd"), name, ...) {
3637
}
3738

3839
finalDir <- system.file("examples", type, name, package = "plotly")
40+
if (edit) {
41+
files <- list.files(finalDir, full.names = TRUE)
42+
scripts <- files[tools::file_ext(files) %in% c("R", "Rmd")]
43+
file.edit(scripts)
44+
}
3945

4046
if (type == "shiny") {
4147
try_library("shiny", "plotly_example")

man/plotly_example.Rd

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

0 commit comments

Comments
 (0)