diff --git a/src/traces/table/plot.js b/src/traces/table/plot.js index 3d71289fa1b..0ac8f2a50db 100644 --- a/src/traces/table/plot.js +++ b/src/traces/table/plot.js @@ -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); }; } diff --git a/test/jasmine/tests/table_test.js b/test/jasmine/tests/table_test.js index 2f58b7f2061..54b6f3dbe39 100644 --- a/test/jasmine/tests/table_test.js +++ b/test/jasmine/tests/table_test.js @@ -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() {