Skip to content

Commit

Permalink
add selectedpoints to uirevision framework
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Nov 9, 2018
1 parent 03baca7 commit 6a9d0d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,7 @@ var layoutUIControlPatterns = [
// same for trace attributes: if `attr` is given it's in layout,
// or with no `attr` we use `trace.uirevision`
var traceUIControlPatterns = [
{pattern: /^selectedpoints$/, attr: 'selectionrevision'},
// "visible" includes trace.transforms[i].styles[j].value.visible
{pattern: /(^|value\.)visible$/, attr: 'legend.uirevision'},
{pattern: /^dimensions\[\d+\]\.constraintrange/},
Expand Down
9 changes: 9 additions & 0 deletions src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,15 @@ function isOnlyOnePointSelected(searchTraces) {
function updateSelectedState(gd, searchTraces, eventData) {
var i, searchInfo, cd, trace;

// before anything else, update preGUI if necessary
for(i = 0; i < searchTraces.length; i++) {
var fullInputTrace = searchTraces[i].cd[0].trace._fullInput;
var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid];
if(tracePreGUI.selectedpoints === undefined) {
tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null;
}
}

if(eventData) {
var pts = eventData.points || [];

Expand Down
9 changes: 9 additions & 0 deletions src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ module.exports = {
'Defaults to `layout.uirevision`.'
].join(' ')
},
selectionrevision: {
valType: 'any',
role: 'info',
editType: 'none',
description: [
'Controls persistence of user-driven changes in selected points',
'from all traces.'
].join(' ')
},
template: {
valType: 'any',
role: 'info',
Expand Down
1 change: 1 addition & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
coerce('datarevision');
var uirevision = coerce('uirevision');
coerce('editrevision', uirevision);
coerce('selectionrevision', uirevision);

coerce('modebar.orientation');
coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5));
Expand Down

0 comments on commit 6a9d0d7

Please sign in to comment.