Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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 src/traces/sankey/base_plot.js
Original file line number Diff line number Diff line change
@@ -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 = [];
40 changes: 22 additions & 18 deletions src/traces/sankey/render.js
Original file line number Diff line number Diff line change
@@ -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() {
@@ -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)
4 changes: 3 additions & 1 deletion src/traces/sankey/select.js
Original file line number Diff line number Diff line change
@@ -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];