Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Upgrade d3 in plotly.js from v3 to v4 #5833

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

Open
wants to merge 55 commits into
base: master
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
87b6741
replace plotly/d3 v3 with d3 v4
archmoj Jul 17, 2021
37686ec
adjust to d3-drag and d3-zoom
archmoj Jul 17, 2021
ef34849
adjust calls to d3.scale and d3.svg
archmoj Jul 14, 2021
131c785
replace .attr({ and .style({ with .attrs({ and .styles({
archmoj Jul 14, 2021
4ca5e45
plot_api enter and exit adjustment
archmoj Jul 18, 2021
6654f6e
sub plots enter and exit adjustment
archmoj Jul 18, 2021
8fbc9b8
lib enter and exit adjustment
archmoj Jul 18, 2021
cc3c454
annotations enter and exit adjustment
archmoj Jul 18, 2021
a43c348
colorbar enter and exit adjustment
archmoj Jul 18, 2021
71d411d
drawing enter and exit adjustment
archmoj Jul 18, 2021
d20a791
errorbars enter and exit adjustment
archmoj Jul 18, 2021
f6e01df
hover enter and exit adjustment
archmoj Jul 18, 2021
d1755e8
layout images enter and exit adjustment
archmoj Jul 18, 2021
b06db2a
legend enter and exit adjustment
archmoj Jul 18, 2021
a0925b2
rangeselector enter and exit adjustment
archmoj Jul 18, 2021
df709e9
rangeslider enter and exit adjustment
archmoj Jul 18, 2021
9b48dca
shapes enter and exit adjustment
archmoj Jul 18, 2021
0f0711f
sliders enter and exit adjustment
archmoj Jul 18, 2021
86b9499
titles enter and exit adjustment
archmoj Jul 18, 2021
dd9b818
updatemenus enter and exit adjustment
archmoj Jul 18, 2021
0dde732
scatter enter and exit adjustment
archmoj Jul 18, 2021
ccc1b63
bar-like enter and exit adjustment
archmoj Jul 18, 2021
3292318
pie-like enter and exit adjustment
archmoj Jul 18, 2021
5e7093b
sunburst, treemap & icicle enter and exit adjustment
archmoj Jul 18, 2021
a6b93d4
heatmap & contour enter and exit adjustment
archmoj Jul 18, 2021
86a0f8d
carpet & contourcarpet enter and exit adjustment
archmoj Jul 18, 2021
3787fb8
box & violin enter and exit adjustment
archmoj Jul 18, 2021
562db25
parcats enter and exit adjustment
archmoj Jul 18, 2021
20aa8da
parcoords enter and exit adjustment
archmoj Jul 18, 2021
6ff6b04
table enter and exit adjustment
archmoj Jul 18, 2021
5a5c9b6
sankey enter and exit adjustment
archmoj Jul 18, 2021
24747dd
choropleth & scattergeo enter and exit adjustment
archmoj Jul 18, 2021
927fff9
ohlc enter and exit adjustment
archmoj Jul 18, 2021
ead3d14
barpolar enter and exit adjustment
archmoj Jul 18, 2021
b2f5877
image enter and exit adjustment
archmoj Jul 18, 2021
efdb078
indicator enter and exit adjustment
archmoj Jul 18, 2021
fd0dce4
move setting subplots bg color into .each
archmoj Jul 15, 2021
0c51567
more styles and attrs adjustments
archmoj Jul 16, 2021
1553518
adjust d3.ease calls
archmoj Jul 17, 2021
712a4b7
adjust outerTickSize to be tickSizeOuter
archmoj Jul 15, 2021
c10335f
get trace_from_cd instead of looking into cd[0]
archmoj Jul 15, 2021
a7b4d43
disable makeUpdate enter true to show lines
archmoj Jul 16, 2021
81a3a1f
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Jul 24, 2021
4fcb937
print number and list of succeeded images
archmoj Jul 24, 2021
01dd5de
pass syntax test
archmoj Jul 24, 2021
18dae68
improve compare test to help maintain certain success rate after each…
archmoj Jul 24, 2021
5f51592
for now throw when success rate is reduced
archmoj Jul 24, 2021
da11d75
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Jul 30, 2021
1ccfe8a
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Aug 27, 2021
5c621d6
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Aug 31, 2021
0ded003
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Oct 5, 2021
5ff9d3b
update package-lock now using node16+npm7
archmoj Oct 5, 2021
9bcad16
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Oct 19, 2021
fb29753
add some smith mocks to the white list
archmoj Oct 19, 2021
6c3b271
Merge remote-tracking branch 'origin/master' into upgrade-d3-to-v4
archmoj Oct 29, 2021
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
Prev Previous commit
Next Next commit
sub plots enter and exit adjustment
  • Loading branch information
archmoj committed Jul 18, 2021
commit 6654f6eec286dfad569ae4fe8c0033f38a4b6241
109 changes: 60 additions & 49 deletions 109 src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1902,14 +1902,16 @@ axes.makeClipPaths = function(gd) {
// have to use class instead
// https://groups.google.com/forum/#!topic/d3-js/6EpAzQ2gU9I
var axClips = fullLayout._clips.selectAll('.axesclip')
.data(clipList, function(d) { return d.x._id + d.y._id; });
.data(clipList, function(d) { return d.x._id + d.y._id; })
.enter()
.append('clipPath');

axClips.enter().append('clipPath')
axClips.exit().remove();

axClips
.classed('axesclip', true)
.attr('id', function(d) { return 'clip' + fullLayout._uid + d.x._id + d.y._id; })
.append('rect');

axClips.exit().remove();
.append('rect');

axClips.each(function(d) {
d3.select(this).select('rect').attrs({
Expand Down Expand Up @@ -2801,11 +2803,13 @@ axes.drawTicks = function(gd, ax, opts) {
}

var ticks = opts.layer.selectAll('path.' + cls)
.data(ax.ticks ? vals : [], tickDataFn);
.data(ax.ticks ? vals : [], tickDataFn)
.enter()
.append('path');

ticks.exit().remove();

ticks.enter().append('path')
ticks
.classed(cls, 1)
.classed('ticks', 1)
.classed('crisp', opts.crisp !== false)
Expand Down Expand Up @@ -2864,11 +2868,13 @@ axes.drawGrid = function(gd, ax, opts) {
}

var grid = opts.layer.selectAll('path.' + cls)
.data(vals, tickDataFn);
.data(vals, tickDataFn)
.enter()
.append('path');

grid.exit().remove();

grid.enter().append('path')
grid
.classed(cls, 1)
.classed('crisp', opts.crisp !== false);

Expand All @@ -2883,6 +2889,8 @@ axes.drawGrid = function(gd, ax, opts) {
hideCounterAxisInsideTickLabels(ax, [GRID_PATH]);

if(typeof opts.path === 'function') grid.attr('d', opts.path);


};

/**
Expand All @@ -2909,11 +2917,13 @@ axes.drawZeroLine = function(gd, ax, opts) {
var show = axes.shouldShowZeroLine(gd, ax, opts.counterAxis);

var zl = opts.layer.selectAll('path.' + cls)
.data(show ? [{x: 0, id: ax._id}] : []);
.data(show ? [{x: 0, id: ax._id}] : [])
.enter()
.append('path');

zl.exit().remove();

zl.enter().append('path')
zl
.classed(cls, 1)
.classed('zl', 1)
.classed('crisp', opts.crisp !== false)
Expand All @@ -2924,9 +2934,8 @@ axes.drawZeroLine = function(gd, ax, opts) {
opts.layer.selectAll('path').sort(function(da, db) {
return idSort(da.id, db.id);
});
});

zl.attr('transform', opts.transFn)
})
.attr('transform', opts.transFn)
.attr('d', opts.path)
.call(Color.stroke, ax.zerolinecolor || Color.defaultLine)
.style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px')
Expand Down Expand Up @@ -2972,45 +2981,47 @@ axes.drawLabels = function(gd, ax, opts) {
var tickAngle = opts.secondary ? 0 : ax.tickangle;
var prevAngle = (ax._prevTickAngles || {})[cls];

var labelsReady = [];

var tickLabels = opts.layer.selectAll('g.' + cls)
.data(ax.showticklabels ? vals : [], tickDataFn);
.data(ax.showticklabels ? vals : [], tickDataFn)
.enter()
.append('g');

var labelsReady = [];
tickLabels.exit().remove();

tickLabels.enter().append('g')
tickLabels
.classed(cls, 1)
.append('text')
// only so tex has predictable alignment that we can
// alter later
.attr('text-anchor', 'middle')
.each(function(d) {
var thisLabel = d3.select(this);
var newPromise = gd._promises.length;

thisLabel
.call(svgTextUtils.positionText, labelFns.xFn(d), labelFns.yFn(d))
.call(Drawing.font, d.font, d.fontSize, d.fontColor)
.text(d.text)
.call(svgTextUtils.convertToTspans, gd);

if(gd._promises[newPromise]) {
// if we have an async label, we'll deal with that
// all here so take it out of gd._promises and
// instead position the label and promise this in
// labelsReady
labelsReady.push(gd._promises.pop().then(function() {
positionLabels(thisLabel, tickAngle);
}));
} else {
// sync label: just position it now.
// only so tex has predictable alignment that we can
// alter later
.attr('text-anchor', 'middle')
.each(function(d) {
var thisLabel = d3.select(this);
var newPromise = gd._promises.length;

thisLabel
.call(svgTextUtils.positionText, labelFns.xFn(d), labelFns.yFn(d))
.call(Drawing.font, d.font, d.fontSize, d.fontColor)
.text(d.text)
.call(svgTextUtils.convertToTspans, gd);

if(gd._promises[newPromise]) {
// if we have an async label, we'll deal with that
// all here so take it out of gd._promises and
// instead position the label and promise this in
// labelsReady
labelsReady.push(gd._promises.pop().then(function() {
positionLabels(thisLabel, tickAngle);
}
});
}));
} else {
// sync label: just position it now.
positionLabels(thisLabel, tickAngle);
}
});

hideCounterAxisInsideTickLabels(ax, [TICK_TEXT]);

tickLabels.exit().remove();

if(opts.repositionOnUpdate) {
tickLabels.each(function(d) {
d3.select(this).select('text')
Expand Down Expand Up @@ -3362,17 +3373,17 @@ function drawDividers(gd, ax, opts) {
var vals = opts.vals;

var dividers = opts.layer.selectAll('path.' + cls)
.data(vals, tickDataFn);
.data(vals, tickDataFn)
.enter()
.insert('path', ':first-child');

dividers.exit().remove();

dividers.enter().insert('path', ':first-child')
dividers
.classed(cls, 1)
.classed('crisp', 1)
.call(Color.stroke, ax.dividercolor)
.style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px');

dividers
.style('stroke-width', Drawing.crispRound(gd, ax.dividerwidth, 1) + 'px')
.attr('transform', opts.transFn)
.attr('d', opts.path);
}
Expand Down
56 changes: 29 additions & 27 deletions 56 src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,17 @@ function plotOne(gd, plotinfo, cdSubplot, transitionOpts, makeOnCompleteCallback
layerData.sort(function(a, b) { return a.i - b.i; });

var layers = plotinfo.plot.selectAll('g.mlayer')
.data(layerData, function(d) { return d.className; });
.data(layerData, function(d) { return d.className; })
.enter()
.append('g');

layers.enter().append('g')
layers.exit().remove();

layers
.attr('class', function(d) { return d.className; })
.classed('mlayer', true)
.classed('rangeplot', plotinfo.isRangePlot);

layers.exit().remove();

layers.order();

layers.each(function(d) {
Expand Down Expand Up @@ -346,28 +348,27 @@ exports.drawFramework = function(gd) {
var subplotData = makeSubplotData(gd);

var subplotLayers = fullLayout._cartesianlayer.selectAll('.subplot')
.data(subplotData, String);

subplotLayers.enter().append('g')
.attr('class', function(d) { return 'subplot ' + d[0]; });

subplotLayers.order();

subplotLayers.exit()
.call(purgeSubplotLayers, fullLayout);

subplotLayers.each(function(d) {
var id = d[0];
var plotinfo = fullLayout._plots[id];

plotinfo.plotgroup = d3.select(this);
makeSubplotLayer(gd, plotinfo);

// make separate drag layers for each subplot,
// but append them to paper rather than the plot groups,
// so they end up on top of the rest
plotinfo.draglayer = ensureSingle(fullLayout._draggers, 'g', id);
});
.data(subplotData, String)
.enter()
.append('g');

subplotLayers.exit().call(purgeSubplotLayers, fullLayout);

subplotLayers
.attr('class', function(d) { return 'subplot ' + d[0]; })
.order()
.each(function(d) {
var id = d[0];
var plotinfo = fullLayout._plots[id];

plotinfo.plotgroup = d3.select(this);
makeSubplotLayer(gd, plotinfo);

// make separate drag layers for each subplot,
// but append them to paper rather than the plot groups,
// so they end up on top of the rest
plotinfo.draglayer = ensureSingle(fullLayout._draggers, 'g', id);
});
};

exports.rangePlot = function(gd, plotinfo, cdSubplot) {
Expand Down Expand Up @@ -528,7 +529,8 @@ function makeSubplotLayer(gd, plotinfo) {
ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.xaxis._id);
ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.yaxis._id);
plotinfo.gridlayer.selectAll('g')
.map(function(d) { return d[0]; })
.nodes()
.map(function(e) { return e.className.baseVal; })
.sort(axisIds.idSort);
}

Expand Down
10 changes: 7 additions & 3 deletions 10 src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
filterPoly = filteredPolygon([[x0, y0]], constants.BENDPX);
}

var outlines = zoomLayer.selectAll('path.select-outline-' + plotinfo.id).data(isDrawMode ? [0] : [1, 2]);
var drwStyle = fullLayout.newshape;
var outlines = zoomLayer.selectAll('path.select-outline-' + plotinfo.id)
.data(isDrawMode ? [0] : [1, 2])
.enter()
.append('path');

outlines.enter()
.append('path')
outlines.exit().remove();

outlines
.attr('class', function(d) { return 'select-outline select-outline-' + d + ' select-outline-' + plotinfo.id; })
.style(isDrawMode ? {
opacity: drwStyle.opacity / 2,
Expand Down
6 changes: 4 additions & 2 deletions 6 src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,17 @@ proto.updateBaseLayers = function(fullLayout, geoLayout) {
});

var join = _this.framework.selectAll('.layer')
.data(layerData, String);
.data(layerData, String)
.enter()
.append('g');

join.exit().each(function(d) {
delete layers[d];
delete basePaths[d];
d3.select(this).remove();
});

join.enter().append('g')
join
.attr('class', function(d) { return 'layer ' + d; })
.each(function(d) {
var layer = layers[d] = d3.select(this);
Expand Down
2 changes: 1 addition & 1 deletion 2 src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ plots.addLinks = function(gd) {
attrs.x = fullLayout._paper.attr('width') - 7;
}

linkContainer.attr(attrs);
linkContainer.attrs(attrs);

var toolspan = linkContainer.select('.js-link-to-tool');
var spacespan = linkContainer.select('.js-link-spacer');
Expand Down
10 changes: 7 additions & 3 deletions 10 src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ proto.updateLayers = function(fullLayout, polarLayout) {
if(!isRadialAxisBelowTraces) layerData.push('radial-axis');

var join = _this.framework.selectAll('.polarsublayer')
.data(layerData, String);
.data(layerData, String)
.enter()
.append('g');

join.enter().append('g')
join.exit().remove();

join
.attr('class', function(d) { return 'polarsublayer ' + d;})
.each(function(d) {
var sel = layers[d] = d3.select(this);
Expand Down Expand Up @@ -1427,7 +1431,7 @@ function snapToVertexAngle(a, vangles) {
function updateElement(sel, showAttr, attrs) {
if(showAttr) {
sel.attr('display', null);
sel.attr(attrs);
sel.attrs(attrs);
} else if(sel) {
sel.attr('display', 'none');
}
Expand Down
8 changes: 6 additions & 2 deletions 8 src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ proto.updateLayers = function(ternaryLayout) {
}

var toplevel = _this.plotContainer.selectAll('g.toplevel')
.data(plotLayers, String);
.data(plotLayers, String)
.enter()
.append('g');

toplevel.exit().remove();

var grids = ['agrid', 'bgrid', 'cgrid'];

toplevel.enter().append('g')
toplevel
.attr('class', function(d) { return 'toplevel ' + d; })
.each(function(d) {
var s = d3.select(this);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.