Skip to content

Geo refactor and lasso/select-box selections #2030

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 42 commits into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4c1ddb8
Introduce geo 2.0
etpinard Sep 21, 2017
482cca1
merge geo axis attrs module into 'main' layout attr module
etpinard Sep 21, 2017
a0be087
add 'geo.center' + improve defaults & :books:
etpinard Sep 21, 2017
e9efdd0
use relayout in geo modeBar buttons
etpinard Sep 21, 2017
9faa1b1
sync pan/scroll interactions into user/full layout
etpinard Sep 21, 2017
d0ea7c9
adapt scattergeo to new geo layers and projection logic
etpinard Sep 21, 2017
a981eb5
adapt choropleth plot and hover (in preparation for selections)
etpinard Sep 21, 2017
44f56dd
prelim stuff for geo selections
etpinard Sep 21, 2017
e53a908
DRY up select test suite
etpinard Sep 21, 2017
0e22ba0
add scattergeo lasso/select
etpinard Sep 21, 2017
397d47c
add choropleth lasso/select
etpinard Sep 21, 2017
825e24d
resolves #1995 - add a miter limit on scattergeo
etpinard Sep 21, 2017
24c2422
clean up and improve geo defaults tests
etpinard Sep 21, 2017
c2b0f9c
resolves #292 - add mucho test for geo pan/scroll interactions
etpinard Sep 21, 2017
3bd89d3
add one geo base layer update test
etpinard Sep 21, 2017
e59c90b
resolves #1698 - add geo_across-antimeridian mock
etpinard Sep 21, 2017
eaf44a8
resolves #1996 - add `geo_scattergeo-out-of-usa`
etpinard Sep 21, 2017
4d9b566
resolves #1486 - add `geo_centering` mock
etpinard Sep 21, 2017
32a29c7
update conic baselines
etpinard Sep 21, 2017
be59f69
update a few scoped baseline
etpinard Sep 21, 2017
36833d4
update `geo_fill` mock
etpinard Sep 22, 2017
7e5bb41
update baseline to show proper marker.opacity
etpinard Sep 22, 2017
a30beea
update other geo baselines
etpinard Sep 22, 2017
fd5bf11
:hocho: obsolete files and logic
etpinard Sep 22, 2017
ae48369
rename temporary geo2.js -> geo.js :tada:
etpinard Sep 22, 2017
5bc2c71
add 'step' name to failure message
etpinard Sep 25, 2017
ab05990
compute geo.midPt more efficiently
etpinard Sep 25, 2017
ce31666
lint (rename params -> exports)
etpinard Sep 25, 2017
eeee911
use {} instead of [] to identify line & fill layers
etpinard Sep 25, 2017
71c5355
improve selection queries
etpinard Sep 25, 2017
a3df09e
use beforeEach in per-trace select tests
etpinard Sep 25, 2017
05e8194
update across antimeridian mock
etpinard Sep 25, 2017
935e4ac
add jasmine test
etpinard Sep 25, 2017
2488f4b
add per-basePlot-module updateFx methods
etpinard Sep 25, 2017
303de22
add `stroke-miterlimit: 2` to base layer lines
etpinard Sep 25, 2017
9bb7d91
use dragElement.unhover to queued Fx.hover calls
etpinard Sep 26, 2017
1c26ec4
add geo.project and use that in scattergeo hover
etpinard Sep 26, 2017
1d2ce2d
handle invalid geo setting that lead to invalid bounds
etpinard Sep 26, 2017
651399e
fix choropleth hover for countries w/ have polygons that cross -180
etpinard Sep 27, 2017
8f9b75a
add _clips and _topclips <g> in makePlotFramework
etpinard Sep 27, 2017
0089488
lint
etpinard Sep 27, 2017
190c733
fix choropleth hover over Antarctica
etpinard Sep 27, 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
2 changes: 1 addition & 1 deletion src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {

var isSizeConstrained = options.width || options.height;

var annTextClip = fullLayout._defs.select('.clips')
var annTextClip = fullLayout._topclips
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcjohnson IMPORTANT: Annotation used to put its clips in fulLayout._defs, even though Annotation draws in toppaper. Clip ids are global to the page, so things still work fine (at in Chrome and FF). But, who knows maybe some other browsers don't apply clip ids outside the <svg> where the <defs> is located.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice find! Definitely not the intent, thanks for cleaning that up!

.selectAll('#' + annClipID)
.data(isSizeConstrained ? [0] : []);

Expand Down
10 changes: 8 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2748,8 +2748,8 @@ Plotly.purge = function purge(gd) {
// makePlotFramework: Create the plot container and axes
// -------------------------------------------------------
function makePlotFramework(gd) {
var gd3 = d3.select(gd),
fullLayout = gd._fullLayout;
var gd3 = d3.select(gd);
var fullLayout = gd._fullLayout;

// Plot container
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
Expand Down Expand Up @@ -2795,9 +2795,15 @@ function makePlotFramework(gd) {
fullLayout._defs = fullLayout._paper.append('defs')
.attr('id', 'defs-' + fullLayout._uid);

fullLayout._clips = fullLayout._defs.append('g')
.classed('clips', true);

fullLayout._topdefs = fullLayout._toppaper.append('defs')
.attr('id', 'topdefs-' + fullLayout._uid);

fullLayout._topclips = fullLayout._topdefs.append('g')
.classed('clips', true);

fullLayout._bgLayer = fullLayout._paper.append('g')
.classed('bglayer', true);

Expand Down
3 changes: 1 addition & 2 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ exports.lsInner = function(gd) {
// Clip so that data only shows up on the plot area.
plotinfo.clipId = 'clip' + fullLayout._uid + subplot + 'plot';

var plotClip = fullLayout._defs.selectAll('g.clips')
.selectAll('#' + plotinfo.clipId)
var plotClip = fullLayout._clips.selectAll('#' + plotinfo.clipId)
.data([0]);

plotClip.enter().append('clipPath')
Expand Down
8 changes: 1 addition & 7 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1620,16 +1620,10 @@ axes.makeClipPaths = function(gd) {
}
}

var defGroup = defs.selectAll('g.clips')
.data([0]);

defGroup.enter().append('g')
.classed('clips', true);

// selectors don't work right with camelCase tags,
// have to use class instead
// https://groups.google.com/forum/#!topic/d3-js/6EpAzQ2gU9I
var axClips = defGroup.selectAll('.axesclip')
var axClips = fullLayout._clips.selectAll('.axesclip')
.data(clipList, function(d) { return d.x._id + d.y._id; });

axClips.enter().append('clipPath')
Expand Down
9 changes: 2 additions & 7 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,10 @@ proto.makeFramework = function() {
var fullLayout = _this.graphDiv._fullLayout;
var clipId = 'clip' + fullLayout._uid + _this.id;

var defGroup = fullLayout._defs.selectAll('g.clips')
.data([0]);
defGroup.enter().append('g')
.classed('clips', true);

_this.clipDef = defGroup.append('clipPath')
_this.clipDef = fullLayout._clips.append('clipPath')
.attr('id', clipId);

_this.clipRect = this.clipDef.append('rect');
_this.clipRect = _this.clipDef.append('rect');

_this.framework = d3.select(_this.container).append('g')
.attr('class', 'geo ' + _this.id)
Expand Down
11 changes: 3 additions & 8 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,17 @@ proto.plot = function(ternaryCalcData, fullLayout) {
proto.makeFramework = function(fullLayout) {
var _this = this;
var ternaryLayout = fullLayout[_this.id];

var defGroup = _this.defs.selectAll('g.clips')
.data([0]);
defGroup.enter().append('g')
.classed('clips', true);
var clipId = _this.clipId = 'clip' + _this.layoutId + _this.id;

// clippath for this ternary subplot
var clipId = _this.clipId = 'clip' + _this.layoutId + _this.id;
_this.clipDef = defGroup.selectAll('#' + clipId)
_this.clipDef = fullLayout._clips.selectAll('#' + clipId)
.data([0]);
_this.clipDef.enter().append('clipPath').attr('id', clipId)
.append('path').attr('d', 'M0,0Z');

// 'relative' clippath (i.e. no translation) for this ternary subplot
var clipIdRelative = _this.clipIdRelative = 'clip-relative' + _this.layoutId + _this.id;
_this.clipDefRelative = defGroup.selectAll('#' + clipIdRelative)
_this.clipDefRelative = fullLayout._clips.selectAll('#' + clipIdRelative)
.data([0]);
_this.clipDefRelative.enter().append('clipPath').attr('id', clipIdRelative)
.append('path').attr('d', 'M0,0Z');
Expand Down
2 changes: 1 addition & 1 deletion src/traces/carpet/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function plotOne(gd, plotinfo, cd) {
fullLayout = gd._fullLayout;

var gridLayer = plotinfo.plot.selectAll('.carpetlayer');
var clipLayer = makeg(fullLayout._defs, 'g', 'clips');
var clipLayer = fullLayout._clips;

var axisLayer = makeg(gridLayer, 'g', 'carpet' + trace.uid).classed('trace', true);
var minorLayer = makeg(axisLayer, 'g', 'minorlayer');
Expand Down
12 changes: 6 additions & 6 deletions src/traces/contour/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function plotOne(gd, plotinfo, cd) {
makeBackground(plotGroup, perimeter, contours);
makeFills(plotGroup, pathinfo, perimeter, contours);
makeLinesAndLabels(plotGroup, pathinfo, gd, cd[0], contours, perimeter);
clipGaps(plotGroup, plotinfo, fullLayout._defs, cd[0], perimeter);
clipGaps(plotGroup, plotinfo, fullLayout._clips, cd[0], perimeter);
}

function emptyPathinfo(contours, plotinfo, cd0) {
Expand Down Expand Up @@ -281,7 +281,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) {
var linegroup = exports.createLines(lineContainer, showLines || showLabels, pathinfo);

var lineClip = exports.createLineClip(lineContainer, clipLinesForLabels,
gd._fullLayout._defs, cd0.trace.uid);
gd._fullLayout._clips, cd0.trace.uid);

var labelGroup = plotgroup.selectAll('g.contourlabels')
.data(showLabels ? [0] : []);
Expand Down Expand Up @@ -403,10 +403,10 @@ exports.createLines = function(lineContainer, makeLines, pathinfo) {
return linegroup;
};

exports.createLineClip = function(lineContainer, clipLinesForLabels, defs, uid) {
exports.createLineClip = function(lineContainer, clipLinesForLabels, clips, uid) {
var clipId = clipLinesForLabels ? ('clipline' + uid) : null;

var lineClip = defs.select('.clips').selectAll('#' + clipId)
var lineClip = clips.selectAll('#' + clipId)
.data(clipLinesForLabels ? [0] : []);
lineClip.exit().remove();

Expand Down Expand Up @@ -630,10 +630,10 @@ exports.drawLabels = function(labelGroup, labelData, gd, lineClip, labelClipPath
}
};

function clipGaps(plotGroup, plotinfo, defs, cd0, perimeter) {
function clipGaps(plotGroup, plotinfo, clips, cd0, perimeter) {
var clipId = 'clip' + cd0.trace.uid;

var clipPath = defs.select('.clips').selectAll('#' + clipId)
var clipPath = clips.selectAll('#' + clipId)
.data(cd0.trace.connectgaps ? [] : [0]);
clipPath.enter().append('clipPath')
.classed('contourclip', true)
Expand Down