Skip to content

Persistent point selection #2135

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 46 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8b60b4e
Mirror point selection in graph data
rreusser Oct 24, 2017
b209a55
Partial stateful select
rreusser Oct 25, 2017
2a04371
Merge branch 'master' into persistent-point-selection
etpinard Nov 2, 2017
6903d31
remove we won't do in this PR
etpinard Nov 2, 2017
3ef323f
mv 'selectedpoints' & 'selectedids' to global trace attrs/defaults
etpinard Nov 2, 2017
1efe144
improve updateSelectedState
etpinard Nov 2, 2017
9f3f58d
introduce new on-select update strategy:
etpinard Nov 2, 2017
782bc66
persistent selections for 'scatter' traces
etpinard Nov 2, 2017
ec0578b
persistent selection for 'scattercarpet' and 'scatteternary'
etpinard Nov 2, 2017
1bd832e
persistent selections for 'box' and 'violin' traces
etpinard Nov 2, 2017
10c5b7b
persistent selection for 'scattergeo'
etpinard Nov 2, 2017
eeace5b
persistent selections for 'choropleth'
etpinard Nov 2, 2017
bf039ab
resolve #1862 - add `marker.opacity` to bar (& histogram) traces
etpinard Nov 2, 2017
5cfadbd
persistent selection for 'bar' & 'histogram' traces
etpinard Nov 2, 2017
f54a08a
persistent selections for 'scattermapbox'
etpinard Nov 2, 2017
d4d1728
don't coerce selected/unselected in scatter3d traces
etpinard Nov 2, 2017
eeaca74
do not implement persistent selections in scattergl traces (for now)
etpinard Nov 2, 2017
5ca8b36
improve point-selection mock
etpinard Nov 2, 2017
4e83ef7
fixup bar/histogram tests
etpinard Nov 2, 2017
67cefad
fixup bar path selector
etpinard Nov 3, 2017
10a2fa9
add selected.marker.size support
etpinard Nov 3, 2017
2fcdb7c
Merge branch 'master' into persistent-point-selection
etpinard Nov 13, 2017
54cc67b
make hover AND select use same event data pipeline
etpinard Nov 15, 2017
638d03d
adapt Histogram.eventData so that it works with selection pts
etpinard Nov 15, 2017
b30fab4
add Scattercarpet.eventData method
etpinard Nov 15, 2017
949b311
add ScatterTernary.eventData method
etpinard Nov 15, 2017
315e632
add Lib.tagSelected made to make selectedpoints work w/ transforms
etpinard Nov 15, 2017
9b79b3f
add support for selection of aggregations
etpinard Nov 15, 2017
9210278
update point-selection baseline
etpinard Nov 15, 2017
261387d
update event-data jasmine tests (mostly adding pointIndex)
etpinard Nov 15, 2017
1859256
add Lib.coerceSelectionMarkerOpacity
etpinard Nov 15, 2017
d3cdd6f
update Drawing.selectedPointStyle
etpinard Nov 16, 2017
451778b
speed up is-pt-index-valid check
etpinard Nov 16, 2017
c8d715b
emit 'normalized' a/b/c coords in scatterternary event data
etpinard Nov 16, 2017
7543dc6
move ptNumber2cdIndex computation to main binning loop
etpinard Nov 16, 2017
a95e47b
Merge pull request #2163 from plotly/persistent-point-selection-compa…
etpinard Nov 16, 2017
9d86a2f
:hocho: selectedids (for now)
etpinard Nov 16, 2017
6437081
add delay in bar select test (to pass on CI)
etpinard Nov 16, 2017
9bbf55b
assert gd.data[i].selectedpoints in per-trace-type select tests
etpinard Nov 16, 2017
9ccccd3
(fixup) Lib.coerceSelectionMarkerOpacity for all selectable traces
etpinard Nov 17, 2017
3d2049c
:lock: down [un]selected styles in mocks
etpinard Nov 17, 2017
a7f06fa
(fixup) rm selectedpoints from scattercarpet for select test
etpinard Nov 17, 2017
80eee22
add selections persist test
etpinard Nov 17, 2017
aff9dbf
fixup selectedpoints -> calcdata for box/violin
etpinard Nov 17, 2017
ab7b8f1
update baseline (box/violin selectedpoints ordering)
etpinard Nov 17, 2017
88fb812
aj-proof [un]selected logic
etpinard Nov 20, 2017
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
8 changes: 7 additions & 1 deletion src/traces/box/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ function calcSelection(cd, trace) {
if(Array.isArray(trace.selectedpoints)) {
for(var i = 0; i < cd.length; i++) {
var pts = cd[i].pts || [];
Lib.tagSelected(pts, trace);
var ptNumber2cdIndex = {};

for(var j = 0; j < pts.length; j++) {
ptNumber2cdIndex[pts[j].i] = j;
}

Lib.tagSelected(pts, trace, ptNumber2cdIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick fixup. I noticed that selectedpoints -> calcdata was off for box and violins while making

peek 2017-11-17 14-26

var gen = v => Math.round(Math.random(v) * 10)
var n = 100
var x = new Array(n).fill(0).map(gen)
var y = new Array(n).fill(0).map(gen)
var c = '#984ea3'
var usmo = 0

Plotly.newPlot(gd, [{
  mode: 'markers',
  x: x,
  y: y,
  marker: {color: c},
  unselected: { marker: {opacity: usmo} }
}, {
  type: 'violin',
  name: 'x',
  x: x,
  points: 'all',
  pointpos: 1.5,
  box: {visible: true},
  yaxis: 'y2',
  marker: {color: c},
  unselected: { marker: {opacity: usmo} }
}, {
  type: 'violin',
  name: 'y',
  y: y,
  points: 'all',
  pointpos: 1.5,
  box: {visible: true},
  xaxis: 'x2',
  marker: {color: c},
  unselected: { marker: {opacity: usmo} }
}], {
  xaxis: {
    domain: [0, 0.48]
  },
  yaxis: {
    domain: [0, 0.48]
  },
  xaxis2: {
    domain: [0.52, 1]
  },
  yaxis2: {
    domain: [0.52, 1]
  },
  showlegend: false,
  dragmode: 'lasso',
  hovermode: 'closest',
  width: 500,
  height: 500
})
gd.on('plotly_selected', d => {
  if(d && d.points && d.points.length) {
    var sel = d.points.map(p => p.pointIndex)
    Plotly.restyle(gd, 'selectedpoints', [sel.slice(), sel.slice(), sel.slice()])
  } else {
    Plotly.restyle(gd, 'selectedpoints', null)
  }
})

}
}
}
Expand Down
12 changes: 8 additions & 4 deletions test/jasmine/tests/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,14 +1338,15 @@ describe('Test that selections persist:', function() {
it('should persist for box', function(done) {
function _assert(expected) {
var selected = gd.calcdata[0][0].pts.map(function(d) { return d.selected; });
expect(selected).toBeCloseToArray(expected.selected, 'selected vals');
expect(selected).toBeCloseToArray(expected.cd, 'selected calcdata vals');
expect(gd.data[0].selectedpoints).toBeCloseToArray(expected.selectedpoints, 'selectedpoints array');
assertPtOpacity('.point', expected);
}

Plotly.plot(gd, [{
type: 'box',
x0: 0,
y: [1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5],
y: [5, 4, 4, 1, 2, 2, 2, 2, 2, 3, 3, 3],
boxpoints: 'all'
}], {
dragmode: 'select',
Expand All @@ -1360,7 +1361,9 @@ describe('Test that selections persist:', function() {
})
.then(function() {
_assert({
selected: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
// N.B. pts in calcdata are sorted
cd: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
selectedpoints: [1, 2, 0],
style: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 1, 1, 1],
});

Expand All @@ -1369,7 +1372,8 @@ describe('Test that selections persist:', function() {
})
.then(function() {
_assert({
selected: [undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1, 1, 1],
cd: [undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1, 1, 1],
selectedpoints: [1, 2, 0],
style: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 1, 1, 1],
});
})
Expand Down