Skip to content

Fix <svg> export of graphs with layout images #846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/images/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var d3 = require('d3');
var Drawing = require('../drawing');
var Axes = require('../../plots/cartesian/axes');
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');

module.exports = function draw(gd) {

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

// Images must be converted to dataURL's for exporting.
function setImage(d) {

var thisImage = d3.select(this);

thisImage.attr('xmlns', xmlnsNamespaces.svg);

var imagePromise = new Promise(function(resolve) {

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

function applyAttributes(d) {

var thisImage = d3.select(this);

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

thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
if(clipAxes) {
thisImage.call(Drawing.setClipUrl, 'clip' + fullLayout._uid + clipAxes);
}
}


Expand Down
2 changes: 1 addition & 1 deletion test/image/export_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var test = require('tape');
var FORMATS = ['svg', 'pdf', 'eps'];

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

// minimum satisfactory file size
var MIN_SIZE = 100;
Expand Down