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

Remove table scroll glyph and capture zone when staticPlot:true #3220

Merged
merged 1 commit into from
Nov 6, 2018
Merged
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
13 changes: 11 additions & 2 deletions src/traces/table/plot.js
Original file line number Diff line number Diff line change
@@ -363,6 +363,15 @@ function renderScrollbarKit(tableControlView, gd, bypassVisibleBar) {
.attr('y2', function(d) {
return d.scrollbarState.scrollableAreaHeight;
});

// Remove scroll glyph and capture zone on static plots
// as they don't render properly when converted to PDF
// in the Chrome PDF viewer
// https://github.com/plotly/streambed/issues/11618
if(gd._context.staticPlot) {
scrollbarGlyph.remove();
scrollbarCaptureZone.remove();
}
}

function renderColumnCellTree(gd, tableControlView, columnBlock, allColumnBlock) {
@@ -720,7 +729,7 @@ function conditionalPanelRerender(gd, tableControlView, cellsColumnBlock, pages,
}
}

function wrapTextMaker(columnBlock, element, tableControlView) {
function wrapTextMaker(columnBlock, element, tableControlView, gd) {
return function wrapText() {
var cellTextHolder = d3.select(element.parentNode);
cellTextHolder
@@ -758,7 +767,7 @@ function wrapTextMaker(columnBlock, element, tableControlView) {
cellTextHolder.selectAll('tspan.line').remove();

// resupply text, now wrapped
populateCellText(cellTextHolder.select('.' + c.cn.cellText), tableControlView, columnBlock);
populateCellText(cellTextHolder.select('.' + c.cn.cellText), tableControlView, columnBlock, gd);
d3.select(element.parentNode.parentNode).call(setCellHeightAndPositionY);
};
}
31 changes: 31 additions & 0 deletions test/jasmine/tests/table_test.js
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ var Table = require('@src/traces/table');
var attributes = require('@src/traces/table/attributes');
var cn = require('@src/traces/table/constants').cn;

var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var supplyAllDefaults = require('../assets/supply_defaults');

var mockMulti = require('@mocks/table_latex_multitrace_scatter.json');
@@ -204,6 +206,35 @@ describe('table', function() {
done();
});
});

it('should remove scroll glyph and capture zone when *staticPlot:true*', function(done) {
var mockCopy = Lib.extendDeep({}, require('@mocks/table_plain_birds.json'));
var gd = createGraphDiv();

function _assert(msg, exp) {
expect(d3.selectAll('.' + cn.scrollbarCaptureZone).size()).toBe(exp.captureZone, msg);
expect(d3.selectAll('.' + cn.scrollbarGlyph).size()).toBe(exp.glyph, msg);
}

// more info in: https://github.com/plotly/streambed/issues/11618

Plotly.plot(gd, mockCopy).then(function() {
_assert('staticPlot:false (base)', {
captureZone: 1,
glyph: 1
});
})
.then(function() { return Plotly.purge(gd); })
.then(function() { return Plotly.plot(gd, mockCopy.data, mockCopy.layout, {staticPlot: true}); })
.then(function() {
_assert('staticPlot:true', {
captureZone: 0,
glyph: 0
});
})
.catch(failTest)
.then(done);
});
});

describe('Rendering with partial attribute support', function() {