From 2d398793afedc93aeedbb79270287f580cebc62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 11 Aug 2016 17:48:04 -0400 Subject: [PATCH 1/3] images: add namespace to layout --- src/components/images/draw.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/images/draw.js b/src/components/images/draw.js index 323847a5b5f..0db86261942 100644 --- a/src/components/images/draw.js +++ b/src/components/images/draw.js @@ -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) { @@ -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(); From 467b631edf66c8933bba33a94a8d570c68ea7578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 11 Aug 2016 17:50:28 -0400 Subject: [PATCH 2/3] images: don't try to clip is clip axes are blank - looks like the browsers ignored clip paths that have corresponding no item, but not all renders can support them (e.g. Batik - which lead to eps and pdf export failures). --- src/components/images/draw.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/images/draw.js b/src/components/images/draw.js index 0db86261942..ad4ead9e3ce 100644 --- a/src/components/images/draw.js +++ b/src/components/images/draw.js @@ -94,7 +94,6 @@ module.exports = function draw(gd) { } function applyAttributes(d) { - var thisImage = d3.select(this); // Axes if specified @@ -142,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); + } } From 4927afbbc09e9c44900e3181e5ea195c2d1ccaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 11 Aug 2016 17:50:56 -0400 Subject: [PATCH 3/3] test: add layout_image mock to list of mock to test export - it seems like a solid candidate to test export with. --- test/image/export_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/image/export_test.js b/test/image/export_test.js index 71bd767fe4c..6d0e7d2557f 100644 --- a/test/image/export_test.js +++ b/test/image/export_test.js @@ -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;