Skip to content
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

Scattergl lasso #1657

Merged
merged 66 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8fe669b
Update gl3d camera
dy Mar 21, 2017
c1a4c0c
Add dep
dy Mar 21, 2017
08f0738
Merge branch 'master' of github.com:plotly/plotly.js
dy Apr 18, 2017
97b827e
Add scattergl box/lasso icons
dy Apr 18, 2017
3d0b325
Fix status
dy Apr 21, 2017
e7e4843
Make rezooming work
dy Apr 21, 2017
6c29193
Get closer to creating scatter for selection
dy Apr 27, 2017
6d4f9a5
Fix progress
dy Apr 27, 2017
cf73fbe
Fix intermediate progress
dy Apr 28, 2017
d3427c0
first working thing
etpinard Apr 28, 2017
190d3c7
Add proper points limits
dy Apr 28, 2017
9921fb9
Add scattergl selection
dy May 3, 2017
4bff013
Fix MVP implementation
dy May 3, 2017
ab07db3
Fix proper points filtering
dy May 8, 2017
1a3ce6d
Add selection to scattergl-fancy
dy May 8, 2017
eb4654d
Make fancy scatter properly select points
dy May 8, 2017
920127d
Lintify
dy May 10, 2017
fb84a06
Resurrect hoveron
dy May 25, 2017
82c71eb
Normalize selected zoom behaviour
dy May 25, 2017
7085146
Fix losing trace reference
dy May 25, 2017
6de41e6
Merge branch 'master' into scattergl-lasso
dy May 25, 2017
86d7d65
Fix fancy scatter
dy May 26, 2017
d21176b
Capitalize cartesian
dy May 26, 2017
8a1c8b8
Recycle cartesian drawFramework
dy May 26, 2017
82610d1
Remove cartesian remnants
dy May 26, 2017
74028eb
Rename glTrace
dy May 26, 2017
e1da55b
Remove extra check
dy May 26, 2017
4c0d822
Lintify
dy May 26, 2017
5d35300
Resurrect gl hover
dy May 26, 2017
7a952b1
Outline the way to implement camera-based selection
dy May 26, 2017
b3bc7cb
Get back cartesian hover mode
dy May 26, 2017
c293529
Lintify
dy May 26, 2017
4e6bff1
comment out mouseContainer removal in scene2d toImage
etpinard May 30, 2017
5d07d99
Fix selection state
dy Jun 6, 2017
6fb7c57
Rearrange scatter run
dy Jun 6, 2017
3cb6ab1
Reduce calc time
dy Jun 6, 2017
b0f0ed3
Reduce calc time more
dy Jun 6, 2017
a74b301
Remove arrays to calcdata
dy Jun 6, 2017
73ab98d
Clean up
dy Jun 6, 2017
8b8d2e3
Use proper gl-scatter2d dep
dy Jun 6, 2017
1451802
bring back scene2d mouseContainer + add updateFx to toggle dragmode
etpinard Jun 6, 2017
de115d3
do not try to recurse into gl-vis object in Lib.minExtend
etpinard Jun 6, 2017
3a30ae1
don't try to remove selection elements when zoomlayer does not exist
etpinard Jun 6, 2017
1c61a47
fixup 'scatter' -> addTraces 'scattergl' test
etpinard Jun 6, 2017
9f57eff
Ignore overcalculating snap-points
dy Jun 6, 2017
c60fb1d
bring back scattergl marker colorscale
etpinard Jun 6, 2017
3921fdd
:hocho: hoveron in scattergl
etpinard Jun 6, 2017
07b4c7c
Fix scatter-fancy lasso
dy Jun 7, 2017
6ac722d
fill scattergl calcdata only when dragmode is set to select/lasso
etpinard Jun 7, 2017
2ceede1
don't try to style plot bg in gl2d case
etpinard Jun 7, 2017
33dda89
don't try to style grid lines either
etpinard Jun 7, 2017
baabafe
don't draw cartesian framework on top of gl2d subplots in staticPlot
etpinard Jun 7, 2017
0b7a924
fixup gl2d dramode logic (:lock: it with tests)
etpinard Jun 9, 2017
d76d64d
call updateFx on doModeBar restyle calls
etpinard Jun 9, 2017
58b3654
rm useless PR diffs
etpinard Jun 9, 2017
bbda3e7
Merge branch 'master' into scattergl-lasso
etpinard Jun 9, 2017
6bfbd83
Ignore resnapping for scatter-fancy
dy Jun 12, 2017
6c08dc3
Lintify
dy Jun 12, 2017
1e4e25d
Merge branch 'master' into scattergl-lasso
etpinard Jun 14, 2017
b92059a
add isDimmed option to fillColor util
etpinard Jun 14, 2017
d4aad3f
add gl2d select/lasso tests
etpinard Jun 14, 2017
c7b551c
try adding delay after first Plotly.plot before gl2d select/lasso tests
etpinard Jun 14, 2017
27811d6
bump gl-scatter2d-sdf to ^1.3.11
etpinard Jun 15, 2017
ab30f93
Merge branch 'master' into scattergl-lasso
etpinard Jun 15, 2017
debdd46
swap 'id' for 'pointNumber' in scattergl selection data
etpinard Jun 15, 2017
9d5d411
skip gl2d lasso/select for now
etpinard Jun 15, 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"mapbox-gl": "^0.22.0",
"matrix-camera-controller": "^2.1.3",
"mouse-change": "^1.4.0",
"mouse-event-offset": "^3.0.2",
"mouse-wheel": "^1.0.2",
"ndarray": "^1.0.18",
"ndarray-fill": "^1.0.2",
Expand Down
5 changes: 2 additions & 3 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ module.exports = function manageModeBar(gd) {
function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
var fullLayout = gd._fullLayout,
fullData = gd._fullData;

var hasCartesian = fullLayout._has('cartesian'),
hasGL3D = fullLayout._has('gl3d'),
hasGeo = fullLayout._has('geo'),
Expand Down Expand Up @@ -121,7 +120,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) {
dragModeGroup = ['zoom2d', 'pan2d'];
}
if((hasCartesian || hasTernary) && isSelectable(fullData)) {
if((hasCartesian || hasTernary || hasGL2D) && isSelectable(fullData)) {
dragModeGroup.push('select2d');
dragModeGroup.push('lasso2d');
}
Expand Down Expand Up @@ -173,7 +172,7 @@ function isSelectable(fullData) {

if(!trace._module || !trace._module.selectPoints) continue;

if(trace.type === 'scatter' || trace.type === 'scatterternary') {
if(trace.type === 'scatter' || trace.type === 'scatterternary' || trace.type === 'scattergl') {
if(scatterSubTypes.hasMarkers(trace) || scatterSubTypes.hasText(trace)) {
selectable = true;
}
Expand Down
5 changes: 3 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ Plotly.plot = function(gd, data, layout, config) {
basePlotModules[i].drawFramework(gd);
}
}

return Lib.syncOrAsync([
subroutines.layoutStyles,
drawAxes,
Expand Down Expand Up @@ -1790,7 +1789,9 @@ Plotly.relayout = function relayout(gd, astr, val) {
flags = specs.flags;

// clear calcdata if required
if(flags.docalc) gd.calcdata = undefined;
if(flags.docalc) {
gd.calcdata = undefined;
}

// fill in redraw sequence

Expand Down
6 changes: 5 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ axes.doAutoRange = function(ax) {
var hasDeps = (ax._min && ax._max && ax._min.length && ax._max.length);

if(ax.autorange && hasDeps) {
ax.range = axes.getAutoRange(ax);
// FIXME: scattergl calls it in async fashion, hence there is .range and _._rl mess
ax.range = ax._rl = axes.getAutoRange(ax);

ax._r = ax.range.slice();
ax._rl = Lib.simpleMap(ax._r, ax.r2l);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting patch. I wonder if this might be fixing an undiscovered bugs(s).

Copy link
Contributor Author

Choose a reason for hiding this comment

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


// doAutoRange will get called on fullLayout,
// but we want to report its results back to layout
Expand Down
15 changes: 11 additions & 4 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
var yIDs = [ya0._id];

// if we're dragging two axes at once, also drag overlays
subplots = [plotinfo].concat((ns && ew) ? plotinfo.overlays : []);
subplots = [plotinfo].concat((ns && ew && plotinfo.overlays) ? plotinfo.overlays : []);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the extra && plotinfo.overlays now?


for(var i = 1; i < subplots.length; i++) {
var subplotXa = subplots[i].xaxis,
Expand Down Expand Up @@ -170,7 +170,6 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}
}
};

dragElement.init(dragOptions);

var x0,
Expand Down Expand Up @@ -387,7 +386,9 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
var axRange = Lib.simpleMap(ax.range, ax.r2l),
v0 = axRange[0] + (axRange[1] - axRange[0]) * centerFraction;
function doZoom(v) { return ax.l2r(v0 + (v - v0) * zoom); }

ax.range = axRange.map(doZoom);

}

if(ew || isSubplotConstrained) {
Expand Down Expand Up @@ -443,7 +444,6 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}

recomputeAxisLists();

if(xActive === 'ew' || yActive === 'ns') {
if(xActive) dragAxList(xa, dx);
if(yActive) dragAxList(ya, dy);
Expand Down Expand Up @@ -504,6 +504,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
// scale the other axis the same about its middle
for(i = 0; i < xa.length; i++) {
xa[i].range = xa[i]._r.slice();

scaleZoom(xa[i], 1 - dy / ph);
}
dx = dy * pw / ph;
Expand All @@ -512,6 +513,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
if(!yActive && xActive.length === 1) {
for(i = 0; i < ya.length; i++) {
ya[i].range = ya[i]._r.slice();

scaleZoom(ya[i], 1 - dx / pw);
}
dy = dx * ph / pw;
Expand Down Expand Up @@ -631,7 +633,6 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}
}
}

gd.emit('plotly_doubleclick', null);
Plotly.relayout(gd, attrs);
}
Expand All @@ -654,6 +655,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
if(axi._r[1] !== axi.range[1]) attrs[axi._name + '.range[1]'] = axi.range[1];

axi.range = axi._input.range = axi._r.slice();

}

updateSubplots([0, 0, pw, ph]);
Expand Down Expand Up @@ -690,7 +692,9 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {

function scaleAndGetShift(ax, scaleFactor) {
if(scaleFactor) {

ax.range = ax._r.slice();

scaleZoom(ax, scaleFactor);
return ax._length * (1 - scaleFactor) / 2;
}
Expand Down Expand Up @@ -811,10 +815,12 @@ function zoomAxRanges(axList, r0Fraction, r1Fraction, linkedAxes) {

axRangeLinear0 = axi._rl[0];
axRangeLinearSpan = axi._rl[1] - axRangeLinear0;

axi.range = [
axi.l2r(axRangeLinear0 + axRangeLinearSpan * r0Fraction),
axi.l2r(axRangeLinear0 + axRangeLinearSpan * r1Fraction)
];

}

// zoom linked axes about their centers
Expand All @@ -829,6 +835,7 @@ function dragAxList(axList, pix) {
for(var i = 0; i < axList.length; i++) {
var axi = axList[i];
if(!axi.fixedrange) {

axi.range = [
axi.l2r(axi._rl[0] - pix / axi._m),
axi.l2r(axi._rl[1] - pix / axi._m)
Expand Down
4 changes: 2 additions & 2 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var dragBox = require('./dragbox');
module.exports = function initInteractions(gd) {
var fullLayout = gd._fullLayout;

if(!fullLayout._has('cartesian') || gd._context.staticPlot) return;
if((!fullLayout._has('cartesian') && !fullLayout._has('gl2d')) || gd._context.staticPlot) return;

var subplots = Object.keys(fullLayout._plots || {}).sort(function(a, b) {
// sort overlays last, then by x axis number, then y axis number
Expand All @@ -38,7 +38,7 @@ module.exports = function initInteractions(gd) {
subplots.forEach(function(subplot) {
var plotinfo = fullLayout._plots[subplot];

if(!fullLayout._has('cartesian')) return;
// if(!fullLayout._has('cartesian')) return;

var xa = plotinfo.xaxis,
ya = plotinfo.yaxis,
Expand Down
4 changes: 3 additions & 1 deletion src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
oldFullLayout._infolayer.select('.' + axIds[i] + 'title').remove();
}
}

//clean selection
oldFullLayout._zoomlayer.selectAll('.select-outline').remove();
};

exports.drawFramework = function(gd) {
Expand Down Expand Up @@ -281,7 +284,6 @@ function makeSubplotData(gd) {
subplotData.push(subplot);
}
}

// main subplots before overlays
subplotData = subplotData.concat(overlays);

Expand Down
1 change: 0 additions & 1 deletion src/plots/cartesian/scale_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = function scaleZoom(ax, factor, centerFraction) {
var rangeLinear = [ax.r2l(ax.range[0]), ax.r2l(ax.range[1])];
var center = rangeLinear[0] + (rangeLinear[1] - rangeLinear[0]) * centerFraction;
var newHalfSpan = (center - rangeLinear[0]) * factor;

ax.range = ax._input.range = [
ax.l2r(center - newHalfSpan),
ax.l2r(center + newHalfSpan)
Expand Down
Loading