Skip to content

Commit f21a522

Browse files
authored
Merge pull request #846 from plotly/export-layout-image-eps-pdf
Fix <svg> export of graphs with layout images
2 parents 92e73fe + 4927afb commit f21a522

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/components/images/draw.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var d3 = require('d3');
1212
var Drawing = require('../drawing');
1313
var Axes = require('../../plots/cartesian/axes');
14+
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1415

1516
module.exports = function draw(gd) {
1617

@@ -52,9 +53,10 @@ module.exports = function draw(gd) {
5253

5354
// Images must be converted to dataURL's for exporting.
5455
function setImage(d) {
55-
5656
var thisImage = d3.select(this);
5757

58+
thisImage.attr('xmlns', xmlnsNamespaces.svg);
59+
5860
var imagePromise = new Promise(function(resolve) {
5961

6062
var img = new Image();
@@ -92,7 +94,6 @@ module.exports = function draw(gd) {
9294
}
9395

9496
function applyAttributes(d) {
95-
9697
var thisImage = d3.select(this);
9798

9899
// Axes if specified
@@ -140,7 +141,9 @@ module.exports = function draw(gd) {
140141
yId = yref ? yref._id : '',
141142
clipAxes = xId + yId;
142143

143-
thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
144+
if(clipAxes) {
145+
thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
146+
}
144147
}
145148

146149

test/image/export_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var test = require('tape');
1414
var FORMATS = ['svg', 'pdf', 'eps'];
1515

1616
// non-exhaustive list of mocks to test
17-
var DEFAULT_LIST = ['0', 'geo_first', 'gl3d_z-range', 'text_export'];
17+
var DEFAULT_LIST = ['0', 'geo_first', 'gl3d_z-range', 'text_export', 'layout_image'];
1818

1919
// minimum satisfactory file size
2020
var MIN_SIZE = 100;

0 commit comments

Comments
 (0)