Skip to content

Commit e78ed04

Browse files
authored
Merge pull request #1928 from plotly/tosvg-fix-marker-gradient-legend
Fix toSVG for marker gradient legend items
2 parents 6f0bded + 20483ff commit e78ed04

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/snapshot/tosvg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports = function toSVG(gd, format) {
113113
}
114114
});
115115

116-
svg.selectAll('.point').each(function() {
116+
svg.selectAll('.point,.scatterpts').each(function() {
117117
var pt = d3.select(this);
118118
var fill = pt.style('fill');
119119

test/jasmine/tests/snapshot_test.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,16 @@ describe('Plotly.Snapshot', function() {
260260
color: ['red', 'blue', 'green']
261261
}
262262
}], {
263-
font: { family: 'Times New Roman' }
263+
font: { family: 'Times New Roman' },
264+
showlegend: true
264265
})
265266
.then(function() {
266267
d3.selectAll('text').each(function() {
267268
var tx = d3.select(this);
268269
expect(tx.style('font-family')).toEqual('\"Times New Roman\"');
269270
});
270271

271-
d3.selectAll('.point').each(function() {
272+
d3.selectAll('.point,.scatterpts').each(function() {
272273
var pt = d3.select(this);
273274
expect(pt.style('fill').substr(0, 6)).toEqual('url(\"#');
274275
});
@@ -280,7 +281,7 @@ describe('Plotly.Snapshot', function() {
280281
var i;
281282

282283
var textElements = svgDOM.getElementsByTagName('text');
283-
expect(textElements.length).toEqual(11);
284+
expect(textElements.length).toEqual(12);
284285

285286
for(i = 0; i < textElements.length; i++) {
286287
expect(textElements[i].style['font-family']).toEqual('\"Times New Roman\"');
@@ -292,6 +293,10 @@ describe('Plotly.Snapshot', function() {
292293
for(i = 0; i < pointElements.length; i++) {
293294
expect(pointElements[i].style.fill.substr(0, 6)).toEqual('url(\"#');
294295
}
296+
297+
var legendPointElements = svgDOM.getElementsByClassName('scatterpts');
298+
expect(legendPointElements.length).toEqual(1);
299+
expect(legendPointElements[0].style.fill.substr(0, 6)).toEqual('url(\"#');
295300
})
296301
.catch(fail)
297302
.then(done);

0 commit comments

Comments
 (0)