Skip to content

Instantly share code, notes, and snippets.

@TorsteinHonsi
Created November 21, 2013 14:36
Show Gist options
  • Save TorsteinHonsi/7582596 to your computer and use it in GitHub Desktop.
Save TorsteinHonsi/7582596 to your computer and use it in GitHub Desktop.
diff --git a/js/modules/exporting.src.js b/js/modules/exporting.src.js
index 398049b..1b37e48 100644
--- a/js/modules/exporting.src.js
+++ b/js/modules/exporting.src.js
@@ -204,6 +204,7 @@ extend(Chart.prototype, {
sourceHeight,
cssWidth,
cssHeight,
+ html,
options = merge(chart.options, additionalOptions); // copy the options and add extra options
// IE compatibility hack for generating SVG content that it doesn't really understand
@@ -239,7 +240,7 @@ extend(Chart.prototype, {
extend(options.chart, {
animation: false,
renderTo: sandbox,
- forExport: true,
+ forExport: options.exporting.allowHTML !== true,
width: sourceWidth,
height: sourceHeight
});
@@ -284,6 +285,18 @@ extend(Chart.prototype, {
chartCopy.destroy();
discardElement(sandbox);
+ // Move HTML into a foreignObject
+ html = svg.match(/<\/svg>(.*?$)/);
+ if (html) {
+ html = '<foreignObject x="0" y="0 width="200" height="200">' +
+ '<body xmlns="http://www.w3.org/1999/xhtml">' +
+ html[1] +
+ '</body>' +
+ '</foreignObject>';
+
+ svg = svg.replace('</svg>', html + '</svg>');
+ }
+
// sanitize
svg = svg
.replace(/zIndex="[^"]+"/g, '')
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment