Skip to content

turn off the selected/unselected API #1223

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

Merged
merged 8 commits into from
May 2, 2018
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 NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## NEW FEATURES & IMPROVEMENTS

* Upgraded to plotly.js v1.35.2. A _huge_ amount of features and improvements have been made since v1.29.2 (i.e., the version included in the last CRAN release of the R package - v4.7.1). Highlights include a complete re-write of `scattergl` to make it nearly feature complete with `scatter`, localization of text rendering (i.e., international translations), and two new trace types (`violin` & `table`). Read more about the v1.32.0 release [here](https://codeburst.io/notes-from-the-latest-plotly-js-release-b035a5b43e21) and the complete list of changes [here](https://github.com/plotly/plotly.js/releases).
* Upgraded to plotly.js v1.37.0. A _huge_ amount of features and improvements have been made since v1.29.2 (i.e., the version included in the last CRAN release of the R package - v4.7.1). Highlights include a complete re-write of `scattergl` to make it nearly feature complete with `scatter`, localization of text rendering (i.e., international translations), and two new trace types (`violin` & `table`). Read more about the v1.32.0 release [here](https://codeburst.io/notes-from-the-latest-plotly-js-release-b035a5b43e21) and the complete list of changes [here](https://github.com/plotly/plotly.js/releases).
* Support for **sf** (simple feature) data structures was added to `plot_ly()`, `plot_mapbox()`, and `plot_geo()` (via the new `add_sf()` function). See [this blog post](https://blog.cpsievert.me/2018/03/30/visualizing-geo-spatial-data-with-sf-and-plotly) for an overview.
* New "special arguments" `stroke`, `strokes`, `alpha_stroke`, `span`, and `spans` were added for easier control over the stroke (i.e., outline) appearance of various (filled) graphical marks. For an overview, see the **sf** blog post linked to in the bullet point above and the new package demos (list all demos with `demo(package = "plotly")`).
* The selection (i.e., linked-brushing) mode can now switch from 'transient' to 'persistent' by holding the 'shift' key. It's still possible to _force_ persistent selection by setting `persistent = TRUE` in `highlight()`, but `persistent = FALSE` (the default) is now recommended since it allows one to switch between [persistent/transient selection](https://plotly-book.cpsievert.me/linking-views-without-shiny.html#transient-versus-persistent-selection) in the browser, rather than at the command line.
Expand Down
2 changes: 1 addition & 1 deletion R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ typedArrayPolyfill <- function() {
# and bundle size at print time.
plotlyMainBundle <- function() {
htmltools::htmlDependency(
"plotlyjs", "1.35.2",
"plotlyjs", "1.37.0",
src = depPath("plotlyjs"),
script = "plotly-latest.min.js",
stylesheet = "plotly-htmlwidgets.css"
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ HTMLWidgets.widget({

// Enable persistent selection when shift key is down
// https://stackoverflow.com/questions/1828613/check-if-a-key-is-down
var persistOnShift = function(e) {
var persistOnShift = function(e) {
if (!e) window.event;
if (e.shiftKey) {
x.highlight.persistent = true;
Expand Down Expand Up @@ -626,7 +626,7 @@ TraceManager.prototype.updateSelection = function(group, keys) {
/ (2) highlight(selected = attrs_selected(...))
*/
// TODO: it would be neat to have a dropdown to dynamically specify these!
$.extend(true, trace, this.highlight.selected, d.selected);
$.extend(true, trace, this.highlight.selected);

// if it is defined, override color with the "dynamic brush color""
if (d.marker) {
Expand Down Expand Up @@ -742,9 +742,8 @@ TraceManager.prototype.updateSelection = function(group, keys) {

if (tracesToDim.length > 0) {
Plotly.restyle(this.gd, {"opacity": opacities}, tracesToDim);
// this is an unfortunate consequence of the selected/unselected API
// https://codepen.io/cpsievert/pen/opOawp
Plotly.restyle(this.gd, {"unselected": {"marker": {"opacity": 1}}});
// turn off the selected/unselected API
Plotly.restyle(this.gd, {"selectedpoints": null});
}

}
Expand Down