Skip to content

Commit

Permalink
Merge pull request #1928 from plotly/tosvg-fix-marker-gradient-legend
Browse files Browse the repository at this point in the history
Fix toSVG for marker gradient legend items
  • Loading branch information
etpinard authored Aug 4, 2017
2 parents 6f0bded + 20483ff commit e78ed04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/snapshot/tosvg.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = function toSVG(gd, format) {
}
});

svg.selectAll('.point').each(function() {
svg.selectAll('.point,.scatterpts').each(function() {
var pt = d3.select(this);
var fill = pt.style('fill');

Expand Down
11 changes: 8 additions & 3 deletions test/jasmine/tests/snapshot_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,16 @@ describe('Plotly.Snapshot', function() {
color: ['red', 'blue', 'green']
}
}], {
font: { family: 'Times New Roman' }
font: { family: 'Times New Roman' },
showlegend: true
})
.then(function() {
d3.selectAll('text').each(function() {
var tx = d3.select(this);
expect(tx.style('font-family')).toEqual('\"Times New Roman\"');
});

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

var textElements = svgDOM.getElementsByTagName('text');
expect(textElements.length).toEqual(11);
expect(textElements.length).toEqual(12);

for(i = 0; i < textElements.length; i++) {
expect(textElements[i].style['font-family']).toEqual('\"Times New Roman\"');
Expand All @@ -292,6 +293,10 @@ describe('Plotly.Snapshot', function() {
for(i = 0; i < pointElements.length; i++) {
expect(pointElements[i].style.fill.substr(0, 6)).toEqual('url(\"#');
}

var legendPointElements = svgDOM.getElementsByClassName('scatterpts');
expect(legendPointElements.length).toEqual(1);
expect(legendPointElements[0].style.fill.substr(0, 6)).toEqual('url(\"#');
})
.catch(fail)
.then(done);
Expand Down

0 comments on commit e78ed04

Please sign in to comment.