Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"alpha-shape": "^1.0.0",
"arraytools": "^1.0.0",
"convex-hull": "^1.0.3",
"d3": "3.5.6",
"d3": "^3.5.12",
"delaunay-triangulate": "^1.1.6",
"es6-promise": "^3.0.2",
"fast-isnumeric": "^1.1.1",
Expand Down Expand Up @@ -73,17 +73,17 @@
"robust-orientation": "^1.1.3",
"sane-topojson": "^1.2.0",
"superscript-text": "^1.0.0",
"tinycolor2": "1.1.2",
"topojson": "^1.6.19"
"tinycolor2": "^1.3.0",
"topojson": "^1.6.20"
},
"devDependencies": {
"brfs": "^1.4.1",
"browserify": "^12.0.1",
"browserify-transform-tools": "^1.5.0",
"brfs": "^1.4.3",
"browserify": "^13.0.0",
"browserify-transform-tools": "^1.5.1",
"ecstatic": "^1.2.0",
"eslint": "^1.10.3",
"falafel": "^1.2.0",
"glob": "^6.0.1",
"glob": "^6.0.4",
"jasmine-core": "^2.3.4",
"karma": "^0.13.15",
"karma-browserify": "^4.4.1",
Expand All @@ -97,7 +97,7 @@
"prettysize": "0.0.3",
"through2": "^2.0.0",
"uglify-js": "^2.5.0",
"watchify": "^3.6.0",
"xml2js": "^0.4.15"
"watchify": "^3.7.0",
"xml2js": "^0.4.16"
}
}
9 changes: 3 additions & 6 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Plotly = require('../../plotly');
var d3 = require('d3');
var isNumeric = require('fast-isnumeric');

var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
var subTypes = require('../../traces/scatter/subtypes');
var makeBubbleSizeFn = require('../../traces/scatter/make_bubble_size_func');

Expand Down Expand Up @@ -449,12 +450,8 @@ drawing.makeTester = function(gd) {
.data([0]);

tester.enter().append('svg')
.attr({
id: 'js-plotly-tester',
xmlns: 'http://www.w3.org/2000/svg',
// odd d3 quirk - need namespace twice??
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
})
.attr('id', 'js-plotly-tester')
.attr(xmlnsNamespaces.svgAttrs)
.style({
position: 'absolute',
left: '-10000px',
Expand Down
22 changes: 22 additions & 0 deletions src/constants/xmlns_namespaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';


exports.xmlns = 'http://www.w3.org/2000/xmlns/';
exports.svg = 'http://www.w3.org/2000/svg';
exports.xlink = 'http://www.w3.org/1999/xlink';

// the 'old' d3 quirk got fix in v3.5.7
// https://github.com/mbostock/d3/commit/a6f66e9dd37f764403fc7c1f26be09ab4af24fed
exports.svgAttrs = {
xmlns: exports.svg,
'xmlns:xlink': exports.xlink
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

15 changes: 11 additions & 4 deletions src/lib/svg_text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@
var Plotly = require('../plotly');
var d3 = require('d3');

var xmlnsNamespaces = require('../constants/xmlns_namespaces');

var util = module.exports = {};

// Append SVG

d3.selection.prototype.appendSVG = function(_svgString) {
var skeleton = '<svg xmlns="http://www.w3.org/2000/svg" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink">' +
_svgString + '</svg>',
dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
var skeleton = [
'<svg xmlns="', xmlnsNamespaces.svg, '" ',
'xmlns:xlink="', xmlnsNamespaces.xlink, '">',
_svgString,
'</svg>'
].join('');

var dom = new DOMParser().parseFromString(skeleton, 'application/xml'),
childNode = dom.documentElement.firstChild;

while(childNode) {
this.node().appendChild(this.node().ownerDocument.importNode(childNode, true));
childNode = childNode.nextSibling;
Expand Down
7 changes: 2 additions & 5 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var Legend = require('../components/legend');
var Shapes = require('../components/shapes');
var Titles = require('../components/titles');
var manageModeBar = require('../components/modebar/manage');
var xmlnsNamespaces = require('../constants/xmlns_namespaces');


/**
Expand Down Expand Up @@ -2567,11 +2568,7 @@ function makePlotFramework(gd) {
}

fullLayout._paperdiv.selectAll('.main-svg')
.attr({
xmlns: 'http://www.w3.org/2000/svg',
// odd d3 quirk - need namespace twice??
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
});
.attr(xmlnsNamespaces.svgAttrs);

fullLayout._defs = fullLayout._paper.append('defs')
.attr('id', 'defs-' + fullLayout._uid);
Expand Down
9 changes: 3 additions & 6 deletions src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var createGeoScale = require('./set_scale');
var createGeoZoom = require('./zoom');
var createGeoZoomReset = require('./zoom_reset');

var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
var constants = require('../../constants/geo_constants');
var topojsonUtils = require('../../lib/topojson_utils');
var topojsonFeature = require('topojson').feature;
Expand Down Expand Up @@ -214,10 +215,7 @@ proto.makeFramework = function() {

var hoverContainer = this.hoverContainer = geoDiv.append('svg');
hoverContainer
.attr({
xmlns:'http://www.w3.org/2000/svg',
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink'
})
.attr(xmlnsNamespaces.svgAttrs)
.style({
'position': 'absolute',
'z-index': 20,
Expand All @@ -226,9 +224,8 @@ proto.makeFramework = function() {

var framework = this.framework = geoDiv.append('svg');
framework
.attr(xmlnsNamespaces.svgAttrs)
.attr({
'xmlns':'http://www.w3.org/2000/svg',
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink',
'position': 'absolute',
'preserveAspectRatio': 'none'
});
Expand Down
2 changes: 1 addition & 1 deletion src/plots/polar/micropolar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll;
width: 300,
height: height + lineHeight,
xmlns: 'http://www.w3.org/2000/svg',
'xmlns:xmlns:xlink': 'http://www.w3.org/1999/xlink',
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
version: '1.1'
});
svgEnter.append('g').classed('legend-axis', true);
Expand Down
15 changes: 9 additions & 6 deletions src/snapshot/tosvg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

'use strict';

var Plotly = require('../plotly'),
d3 = require('d3');
var Plotly = require('../plotly');
var d3 = require('d3');

var xmlnsNamespaces = require('../constants/xmlns_namespaces');


module.exports = function toSVG(gd, format) {

Expand Down Expand Up @@ -139,8 +142,8 @@ module.exports = function toSVG(gd, format) {

// fix for IE namespacing quirk?
// http://stackoverflow.com/questions/19610089/unwanted-namespaces-on-svg-markup-when-using-xmlserializer-in-javascript-with-ie
svg.node().setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg');
svg.node().setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns', xmlnsNamespaces.svg);
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns:xlink', xmlnsNamespaces.xlink);

var s = new window.XMLSerializer().serializeToString(svg.node());
s = Plotly.util.html_entity_decode(s);
Expand All @@ -154,8 +157,8 @@ function insertGlImage(fullLayout, scene, opts) {

fullLayout._glimages.append('svg:image')
.attr({
xmlns:'http://www.w3.org/2000/svg',
'xlink:xlink:href': imageData, // odd d3 quirk, need namespace twice
xmlns: xmlnsNamespaces.svg,
'xlink:href': imageData,
x: opts.x,
y: opts.y,
width: opts.width,
Expand Down
5 changes: 3 additions & 2 deletions src/traces/heatmap/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var tinycolor = require('tinycolor2');
var Plotly = require('../../plotly');
var Lib = require('../../lib');
var getColorscale = require('../../components/colorscale/get_scale');
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');

var maxRowLength = require('./max_row_length');

Expand Down Expand Up @@ -372,8 +373,8 @@ function plotOne(gd, plotinfo, cd) {
.classed(id, true)
.datum(cd[0])
.attr({
xmlns: 'http://www.w3.org/2000/svg',
'xlink:xlink:href': canvas.toDataURL('image/png'), // odd d3 quirk, need namespace twice
xmlns: xmlnsNamespaces.svg,
'xlink:href': canvas.toDataURL('image/png'),
height: imageHeight,
width: imageWidth,
x: left,
Expand Down