Skip to content

Commit f3f1a5d

Browse files
committed
fixing multitrace drag bug 2
1 parent 6f21697 commit f3f1a5d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/traces/table/plot.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ module.exports = function plot(gd, calcdata) {
108108
var getter = function(dd) {return (d === dd ? d3.event.x : dd.x) + dd.columnWidth / 2;};
109109
d.x = Math.max(-c.overdrag, Math.min(d.calcdata.width + c.overdrag - d.columnWidth, d3.event.x));
110110

111-
var sortableColumns = [].concat.apply([], yColumn.map(function(g) {return g;}))
112-
.map(function(g) {return g.__data__})
113-
.filter(function(dd) {return dd.calcdata.key === d.calcdata.key});
111+
var sortableColumns = flatData(yColumn).filter(function(dd) {return dd.calcdata.key === d.calcdata.key});
114112
var newOrder = sortableColumns.sort(function(a, b) {return getter(a) - getter(b);});
115113
newOrder.forEach(function(dd, i) {
116114
dd.xIndex = i;
@@ -234,6 +232,11 @@ module.exports = function plot(gd, calcdata) {
234232
updateBlockYPosition(null, cellsColumnBlock, tableControlView);
235233
};
236234

235+
function flatData(selection) {
236+
return [].concat.apply([], selection.map(function(g) {return g;}))
237+
.map(function(g) {return g.__data__});
238+
}
239+
237240
function renderScrollbarKit(tableControlView, gd) {
238241

239242
function calcTotalHeight(d) {
@@ -745,8 +748,7 @@ function updateBlockYPosition(gd, cellsColumnBlock, tableControlView) {
745748
}
746749

747750
function makeDragRow(gd, tableControlView, optionalMultiplier, optionalPosition) {
748-
return function dragRow() {
749-
var d = tableControlView.node().__data__;
751+
return function dragRow(d) {
750752
var multiplier = optionalMultiplier || d.scrollbarState.dragMultiplier;
751753
d.scrollY = optionalPosition === void(0) ? d.scrollY + multiplier * d3.event.dy : optionalPosition;
752754
var cellsColumnBlock = tableControlView.selectAll('.yColumn').selectAll('.columnBlock').filter(cellsBlock);

test/image/mocks/table_latex_multitrace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"layout": {
33
"width": 620,
4-
"height": 560,
4+
"height": 400,
55
"title": "Half and Double Angles"
66
},
77

0 commit comments

Comments
 (0)