Skip to content

Commit 1437d64

Browse files
committed
Merge branch 'master' into input-events
2 parents f62c50e + c6b8a5d commit 1437d64

5 files changed

Lines changed: 24 additions & 7 deletions

File tree

NEWS.md

Lines changed: 2 additions & 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

@@ -24,6 +25,7 @@
2425
* Fixed issue where **dplyr** groups caused a problem in the ordering of data arrays passed to `marker` objects (#1351).
2526
* In some cases, a `ggplotly()` colorbar would cause issues with hover behavior, which is now fixed (#1381).
2627
* An articial marker no longer appears when clearing a crosstalk selection of a plot with a colorbar (#1406).
28+
* Clearing a highlight event via crosstalk no longer deletes all the traces added since initial draw (#1436).
2729
* Recursive attribute validation is now only performed on recursive objects (#1315).
2830

2931
# 4.8.0

R/orca.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,14 @@ orca_serve <- function(port = 5151, mathjax = FALSE, safe = FALSE, request_limit
204204
)
205205
}
206206

207+
correct_orca <- function() {
208+
orca_help <- processx::run("orca", "-h")
209+
grepl("plotly", orca_help[["stdout"]], ignore.case = TRUE)
210+
}
211+
207212

208213
orca_available <- function() {
209-
if (Sys.which("orca") == "") {
214+
if (Sys.which("orca") == "" || !correct_orca()) {
210215
stop(
211216
"The orca command-line utility is required for this functionality.\n\n",
212217
"Please follow the installation instructions here -- https://github.com/plotly/orca#installation",

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")

inst/htmlwidgets/plotly.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ TraceManager.prototype.updateSelection = function(group, keys) {
639639
var nNewTraces = this.gd.data.length - this.origData.length;
640640
if (keys === null || !this.highlight.persistent && nNewTraces > 0) {
641641
var tracesToRemove = [];
642-
for (var i = this.origData.length; i < this.gd.data.length; i++) {
643-
tracesToRemove.push(i);
642+
for (var i = 0; i < this.gd.data.length; i++) {
643+
if (this.gd.data[i]._isCrosstalkTrace) tracesToRemove.push(i);
644644
}
645645
Plotly.deleteTraces(this.gd, tracesToRemove);
646646
this.groupSelections[group] = keys;
@@ -722,6 +722,7 @@ TraceManager.prototype.updateSelection = function(group, keys) {
722722
// (necessary for updating frames to reflect the selection traces)
723723
trace._originalIndex = i;
724724
trace._newIndex = this.gd._fullData.length + traces.length;
725+
trace._isCrosstalkTrace = true;
725726
traces.push(trace);
726727
}
727728
}

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)