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

Avoid conflict between sankey mocked x and y axes with cartesian xy subplot #6268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/traces/sankey/base_plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function subplotUpdateFx(gd, index) {
yaxes: [yaxis],
doneFnCompleted: function(selection) {
var traceNow = gd._fullData[index];
if(!traceNow.node) return;
var newGroups;
var oldGroups = traceNow.node.groups.slice();
var newGroup = [];
Expand Down
40 changes: 22 additions & 18 deletions src/traces/sankey/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ function switchToSankeyFormat(nodes) {

// scene graph
module.exports = function(gd, svg, calcData, layout, callbacks) {
var cartesian = gd._fullLayout._subplots.cartesian;

// To prevent animation on first render
var firstRender = false;
Lib.ensureSingle(gd._fullLayout._infolayer, 'g', 'first-render', function() {
Expand Down Expand Up @@ -822,24 +824,26 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
.style('pointer-events', 'auto')
.attr('transform', sankeyTransform);

sankey.each(function(d, i) {
gd._fullData[i]._sankey = d;
// Create dragbox if missing
var dragboxClassName = 'bgsankey-' + d.trace.uid + '-' + i;
Lib.ensureSingle(gd._fullLayout._draggers, 'rect', dragboxClassName);

gd._fullData[i]._bgRect = d3.select('.' + dragboxClassName);

// Style dragbox
gd._fullData[i]._bgRect
.style('pointer-events', 'all')
.attr('width', d.width)
.attr('height', d.height)
.attr('x', d.translateX)
.attr('y', d.translateY)
.classed('bgsankey', true)
.style({fill: 'transparent', 'stroke-width': 0});
});
if(cartesian.indexOf('xy') === -1) {
sankey.each(function(d, i) {
gd._fullData[i]._sankey = d;
// Create dragbox if missing
var dragboxClassName = 'bgsankey-' + d.trace.uid + '-' + i;
Lib.ensureSingle(gd._fullLayout._draggers, 'rect', dragboxClassName);

gd._fullData[i]._bgRect = d3.select('.' + dragboxClassName);

// Style dragbox
gd._fullData[i]._bgRect
.style('pointer-events', 'all')
.attr('width', d.width)
.attr('height', d.height)
.attr('x', d.translateX)
.attr('y', d.translateY)
.classed('bgsankey', true)
.style({fill: 'transparent', 'stroke-width': 0});
});
}

sankey.transition()
.ease(c.ease).duration(c.duration)
Expand Down
4 changes: 3 additions & 1 deletion src/traces/sankey/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module.exports = function selectPoints(searchInfo, selectionTester) {
var selection = [];
var fullData = cd[0].trace;

var nodes = fullData._sankey.graph.nodes;
var sankey = fullData._sankey;
if(!sankey) return [];
var nodes = sankey.graph.nodes;

for(var i = 0; i < nodes.length; i++) {
var node = nodes[i];
Expand Down