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
legend enter and exit adjustment
  • Loading branch information
archmoj committed Jul 18, 2021
commit b06db2acd10e2b4bdb3a31d264eb51e767e8d37a
33 changes: 24 additions & 9 deletions 33 src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,44 @@ function _draw(gd, legendObj) {
}

var scrollBar = Lib.ensureSingle(legend, 'rect', 'scrollbar', function(s) {
s.attr(constants.scrollBarEnterAttrs)
s.attrs(constants.scrollBarEnterAttrs)
.call(Color.fill, constants.scrollBarColor);
});

var groups = scrollBox.selectAll('g.groups').data(legendData);
groups.enter().append('g').attr('class', 'groups');
var groups = scrollBox.selectAll('g.groups')
.data(legendData)
.enter()
.append('g');

groups.exit().remove();

var traces = groups.selectAll('g.traces').data(Lib.identity);
traces.enter().append('g').attr('class', 'traces');
groups
.attr('class', 'groups');

var traces = groups.selectAll('g.traces')
.data(Lib.identity)
.enter()
.append('g');

traces.exit().remove();

traces
.attr('class', 'traces');

traces.style('opacity', function(d) {
var trace = d[0].trace;
if(Registry.traceIs(trace, 'pie-like')) {
return hiddenSlices.indexOf(d[0].label) !== -1 ? 0.5 : 1;
} else {
return trace.visible === 'legendonly' ? 0.5 : 1;
}
})
.each(function() { d3.select(this).call(drawTexts, gd, legendObj); })
.call(style, gd, legendObj)
.each(function() { if(!inHover) d3.select(this).call(setupTraceToggle, gd); });
});

traces.each(function() { d3.select(this).call(drawTexts, gd, legendObj); });

traces
.call(style, gd, legendObj)
.each(function() { if(!inHover) d3.select(this).call(setupTraceToggle, gd); });

Lib.syncOrAsync([
Plots.previousPromises,
Expand Down
190 changes: 119 additions & 71 deletions 190 src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,28 @@ module.exports = function style(s, gd, legend) {
layers.attr('transform', strTranslate(0, markerOffsetY));
}

var fill = layers
.selectAll('g.legendfill')
.data([d]);
fill.enter().append('g')
layers.selectAll('g.legendfill')
.data([d])
.enter()
.append('g')
.classed('legendfill', true);

var line = layers
.selectAll('g.legendlines')
.data([d]);
line.enter().append('g')
layers.selectAll('g.legendlines')
.data([d])
.enter()
.append('g')
.classed('legendlines', true);

var symbol = layers
.selectAll('g.legendsymbols')
.data([d]);
symbol.enter().append('g')
var symbol = layers.selectAll('g.legendsymbols')
.data([d])
.enter()
.append('g')
.classed('legendsymbols', true);

symbol.selectAll('g.legendpoints')
.data([d])
.enter().append('g')
.enter()
.append('g')
.classed('legendpoints', true);
})
.each(styleSpatial)
Expand Down Expand Up @@ -141,10 +142,15 @@ module.exports = function style(s, gd, legend) {
var this3 = d3.select(this);

var fill = this3.select('.legendfill').selectAll('path')
.data(showFill || showGradientFill ? [d] : []);
fill.enter().append('path').classed('js-fill', true);
.data(showFill || showGradientFill ? [d] : [])
.enter()
.append('path');

fill.exit().remove();
fill.attr('d', pathStart + 'h' + itemWidth + 'v6h-' + itemWidth + 'z')

fill
.classed('js-fill', true)
.attr('d', pathStart + 'h' + itemWidth + 'v6h-' + itemWidth + 'z')
.call(showFill ? Drawing.fillGroupStyle : fillGradient);

if(showLine || showGradientLine) {
Expand All @@ -154,17 +160,21 @@ module.exports = function style(s, gd, legend) {
}

var line = this3.select('.legendlines').selectAll('path')
.data(showLine || showGradientLine ? [dMod] : []);
line.enter().append('path').classed('js-line', true);
.data(showLine || showGradientLine ? [dMod] : [])
.enter()
.append('path');

line.exit().remove();

// this is ugly... but you can't apply a gradient to a perfectly
// horizontal or vertical line. Presumably because then
// the system doesn't know how to scale vertical variation, even
// though there *is* no vertical variation in this case.
// so add an invisibly small angle to the line
// This issue (and workaround) exist across (Mac) Chrome, FF, and Safari
line.attr('d', pathStart + (showGradientLine ? 'l' + itemWidth + ',0.0001' : 'h' + itemWidth))
line
.classed('js-line', true)
// this is ugly... but you can't apply a gradient to a perfectly
// horizontal or vertical line. Presumably because then
// the system doesn't know how to scale vertical variation, even
// though there *is* no vertical variation in this case.
// so add an invisibly small angle to the line
// This issue (and workaround) exist across (Mac) Chrome, FF, and Safari
.attr('d', pathStart + (showGradientLine ? 'l' + itemWidth + ',0.0001' : 'h' + itemWidth))
.call(showLine ? Drawing.lineGroupStyle : lineGradient);
}

Expand Down Expand Up @@ -254,25 +264,35 @@ module.exports = function style(s, gd, legend) {
var ptgroup = d3.select(this).select('g.legendpoints');

var pts = ptgroup.selectAll('path.scatterpts')
.data(showMarker ? dMod : []);
// make sure marker is on the bottom, in case it enters after text
pts.enter().insert('path', ':first-child')
.classed('scatterpts', true)
.attr('transform', centerTransform);
.data(showMarker ? dMod : [])
// make sure marker is on the bottom, in case it enters after text
.enter()
.insert('path', ':first-child');

pts.exit().remove();
pts.call(Drawing.pointStyle, tMod, gd);

pts
.classed('scatterpts', true)
.attr('transform', centerTransform)
.call(Drawing.pointStyle, tMod, gd);

// 'mrc' is set in pointStyle and used in textPointStyle:
// constrain it here
if(showMarker) dMod[0].mrc = 3;

var txt = ptgroup.selectAll('g.pointtext')
.data(showText ? dMod : []);
txt.enter()
.append('g').classed('pointtext', true)
.append('text').attr('transform', centerTransform);
.data(showText ? dMod : [])
.enter()
.append('g');

txt.exit().remove();
txt.selectAll('text').call(Drawing.textPointStyle, tMod, gd);

txt
.classed('pointtext', true)
.append('text')
.attr('transform', centerTransform)
.selectAll('text')
.call(Drawing.textPointStyle, tMod, gd);
}

function styleWaterfalls(d) {
Expand All @@ -294,13 +314,17 @@ module.exports = function style(s, gd, legend) {
[['increasing', 'M-6,-6V6H6Z'], ['decreasing', 'M6,6V-6H-6Z']];
}

var pts = d3.select(this).select('g.legendpoints')
.selectAll('path.legendwaterfall')
.data(ptsData);
pts.enter().append('path').classed('legendwaterfall', true)
var pts = d3.select(this).select('g.legendpoints').selectAll('path.legendwaterfall')
.data(ptsData)
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legendwaterfall', true)
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

pts.each(function(dd) {
var pt = d3.select(this);
Expand Down Expand Up @@ -333,13 +357,17 @@ module.exports = function style(s, gd, legend) {
var isVisible = (!desiredType) ? Registry.traceIs(trace, 'bar') :
(trace.visible && trace.type === desiredType);

var barpath = d3.select(lThis).select('g.legendpoints')
.selectAll('path.legend' + desiredType)
.data(isVisible ? [d] : []);
barpath.enter().append('path').classed('legend' + desiredType, true)
var barpath = d3.select(lThis).select('g.legendpoints').selectAll('path.legend' + desiredType)
.data(isVisible ? [d] : [])
.enter()
.append('path');

barpath.exit().remove();

barpath
.classed('legend' + desiredType, true)
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', centerTransform);
barpath.exit().remove();

barpath.each(function(d) {
var p = d3.select(this);
Expand Down Expand Up @@ -386,14 +414,18 @@ module.exports = function style(s, gd, legend) {
function styleBoxes(d) {
var trace = d[0].trace;

var pts = d3.select(this).select('g.legendpoints')
.selectAll('path.legendbox')
.data(trace.visible && Registry.traceIs(trace, 'box-violin') ? [d] : []);
pts.enter().append('path').classed('legendbox', true)
var pts = d3.select(this).select('g.legendpoints').selectAll('path.legendbox')
.data(trace.visible && Registry.traceIs(trace, 'box-violin') ? [d] : [])
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legendbox', true)
// if we want the median bar, prepend M6,0H-6
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', centerTransform);
pts.exit().remove();

pts.each(function() {
var p = d3.select(this);
Expand Down Expand Up @@ -424,17 +456,21 @@ module.exports = function style(s, gd, legend) {
function styleCandles(d) {
var trace = d[0].trace;

var pts = d3.select(this).select('g.legendpoints')
.selectAll('path.legendcandle')
.data(trace.visible && trace.type === 'candlestick' ? [d, d] : []);
pts.enter().append('path').classed('legendcandle', true)
var pts = d3.select(this).select('g.legendpoints').selectAll('path.legendcandle')
.data(trace.visible && trace.type === 'candlestick' ? [d, d] : [])
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legendcandle', true)
.attr('d', function(_, i) {
if(i) return 'M-15,0H-8M-8,6V-6H8Z'; // increasing
return 'M15,0H8M8,-6V6H-8Z'; // decreasing
})
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

pts.each(function(_, i) {
var p = d3.select(this);
Expand All @@ -451,17 +487,21 @@ module.exports = function style(s, gd, legend) {
function styleOHLC(d) {
var trace = d[0].trace;

var pts = d3.select(this).select('g.legendpoints')
.selectAll('path.legendohlc')
.data(trace.visible && trace.type === 'ohlc' ? [d, d] : []);
pts.enter().append('path').classed('legendohlc', true)
var pts = d3.select(this).select('g.legendpoints').selectAll('path.legendohlc')
.data(trace.visible && trace.type === 'ohlc' ? [d, d] : [])
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legendohlc', true)
.attr('d', function(_, i) {
if(i) return 'M-15,0H0M-8,-6V0'; // increasing
return 'M15,0H0M8,6V0'; // decreasing
})
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

pts.each(function(_, i) {
var p = d3.select(this);
Expand Down Expand Up @@ -490,13 +530,17 @@ module.exports = function style(s, gd, legend) {
var isVisible = (!desiredType) ? Registry.traceIs(trace, desiredType) :
(trace.visible && trace.type === desiredType);

var pts = d3.select(lThis).select('g.legendpoints')
.selectAll('path.legend' + desiredType)
.data(isVisible ? [d] : []);
pts.enter().append('path').classed('legend' + desiredType, true)
var pts = d3.select(lThis).select('g.legendpoints').selectAll('path.legend' + desiredType)
.data(isVisible ? [d] : [])
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legend' + desiredType, true)
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', centerTransform);
pts.exit().remove();

if(pts.size()) {
var cont = (trace.marker || {}).line;
Expand Down Expand Up @@ -589,13 +633,17 @@ module.exports = function style(s, gd, legend) {
}
}

var pts = d3.select(this).select('g.legendpoints')
.selectAll('path.legend3dandfriends')
.data(ptsData);
pts.enter().append('path').classed('legend3dandfriends', true)
var pts = d3.select(this).select('g.legendpoints').selectAll('path.legend3dandfriends')
.data(ptsData)
.enter()
.append('path');

pts.exit().remove();

pts
.classed('legend3dandfriends', true)
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

pts.each(function(dd, i) {
var pt = d3.select(this);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.