Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 510b617

Browse filesBrowse files
committed
Add 'plotly_selecting' to acceptable 'on' events
1 parent 9e4e5cc commit 510b617
Copy full SHA for 510b617

File tree

3 files changed

+6
-5
lines changed
Filter options

3 files changed

+6
-5
lines changed

‎R/highlight.R

Copy file name to clipboardExpand all lines: R/highlight.R
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ highlight <- function(p, on = "plotly_click", off,
145145
# main (non-plotly.js) spec passed along to HTMLwidgets.renderValue()
146146
p$x$highlight <- list(
147147
# NULL may be used to disable on/off events
148-
on = if (!is.null(on)) match.arg(on, paste0("plotly_", c("click", "hover", "selected"))),
148+
on = if (!is.null(on)) match.arg(on, paste0("plotly_", c("click", "hover", "selected", "selecting"))),
149149
off = if (is.default(off)) off else if (!is.null(off)) match.arg(off, off_options),
150150
persistent = persistent,
151151
dynamic = dynamic,

‎R/utils.R

Copy file name to clipboardExpand all lines: R/utils.R
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ supply_highlight_attrs <- function(p) {
402402
# add HTML dependencies, set a sensible dragmode default, & throw messages
403403
if (hasKeys) {
404404
p$x$layout$dragmode <- p$x$layout$dragmode %|D|%
405-
default(switch(p$x$highlight$on %||% "", plotly_selected = "select") %||% "zoom")
405+
default(switch(p$x$highlight$on %||% "", plotly_selected = "select", plotly_selecting = "select") %||% "zoom")
406406
if (is.default(p$x$highlight$off)) {
407407
message(
408408
sprintf(

‎demo/crosstalk-highlight-intro.R

Copy file name to clipboardExpand all lines: demo/crosstalk-highlight-intro.R
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ sd <- SharedData$new(df, ~patient)
1616
p <- plot_ly(sd, x = ~visit, y = ~perc, color = I("black"),
1717
text = ~paste("Patient:", patient)) %>%
1818
group_by(patient) %>%
19-
add_trace(mode = "markers+lines") %>%
20-
highlight("plotly_selected")
19+
add_trace(mode = "markers+lines")
20+
21+
highlight(p, "plotly_selecting", color = "red")
2122

2223
# Since crosstalk's SharedData object was supplied to plot_ly() with a key of
2324
# patient, it knows to highlight any lines/markers matching the selected patient(s).
2425
# By default, the "on trigger" is "plotly_click", but we've changed that to
25-
# "plotly_selected", which corresponds to click and drag mouse events.
26+
# "plotly_selecting", which corresponds to click and drag mouse events.
2627
# Plotly provides two types of drag modes that will trigger a "plotly_selected"
2728
# event: "lasso" and "select". You can change the dragmode interactively via
2829
# the modebar and/or set the default dragmode via `layout()`.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.