diff --git a/src/snapshot/tosvg.js b/src/snapshot/tosvg.js index 507bab751fd..a4dc988a0f2 100644 --- a/src/snapshot/tosvg.js +++ b/src/snapshot/tosvg.js @@ -115,7 +115,7 @@ module.exports = function toSVG(gd, format, scale) { } }); - svg.selectAll('.point, .scatterpts, .legendfill>path, .legendlines>path, .cbfill').each(function() { + svg.selectAll('.point, .scatterpts, .legendfill>path, .legendlines>path, path.legend3dandfriends, .cbfill').each(function() { var pt = d3.select(this); // similar to font family styles above, diff --git a/test/jasmine/tests/snapshot_test.js b/test/jasmine/tests/snapshot_test.js index 62743768fca..1111707cbbb 100644 --- a/test/jasmine/tests/snapshot_test.js +++ b/test/jasmine/tests/snapshot_test.js @@ -344,6 +344,24 @@ describe('Plotly.Snapshot', function() { .catch(failTest) .then(done); }); + + it('- legend3dandfriends case', function(done) { + var fig = Lib.extendDeep({}, require('@mocks/geo_choropleth-legend.json')); + + Plotly.plot(gd, fig) + .then(function() { return Plotly.Snapshot.toSVG(gd); }) + .then(function(svg) { + var svgDOM = parser.parseFromString(svg, 'image/svg+xml'); + + var fillItems = svgDOM.getElementsByClassName('legend3dandfriends'); + expect(fillItems.length).toBe(4, '# of legend items'); + for(var i = 0; i < fillItems.length; i++) { + checkURL(fillItems[i].style.fill, 'fill gradient ' + i); + } + }) + .catch(failTest) + .then(done); + }); }); it('should adapt *viewBox* attribute under *scale* option', function(done) {