Created
April 18, 2012 22:23
-
-
Save alecgorge/2417034 to your computer and use it in GitHub Desktop.
Go to the print friendly version on anything using HighCharts and run the bookmarklet. It will turn all the SVGs into copyable PNGs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(a){var b=function(){a(".highcharts-container svg").map(function(){var b=a(this).parent(),c=b.html();b.html(""),a("<canvas></canvas>").css("width",b.css("width")).css("height",b.css("height")).appendTo(b);var d=b.find("canvas")[0];canvg(d,c,{ignoreMouse:!0,ignoreAnimation:!0,renderCallback:function(){var a=d.toDataURL("image/png");b.html('<img src="'+a+'"/>')}})})};if(typeof window.canvg!="undefined"){b();return}var c=["http://canvg.googlecode.com/svn/trunk/rgbcolor.js","http://canvg.googlecode.com/svn/trunk/canvg.js"];a.getScript(c[0],function(){a.getScript(c[1],function(){b()})})})(jQuery) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var go = function () { | |
$('.highcharts-container svg').map(function () { | |
var $parent = $(this).parent() | |
, svg = $parent.html() | |
; | |
$parent.html(''); | |
$('<canvas></canvas>').css('width', $parent.css('width')).css('height', $parent.css('height')).appendTo($parent); | |
var ca = $parent.find('canvas')[0]; | |
canvg(ca, svg, {ignoreMouse: true, ignoreAnimation: true, renderCallback: function () { | |
var img = ca.toDataURL('image/png') | |
$parent.html('<img src="'+img+'" />') | |
}}) | |
}) | |
}; | |
if(typeof window.canvg != 'undefined') { | |
go(); return; | |
} | |
// load the canvg library | |
var urls = ["http://canvg.googlecode.com/svn/trunk/rgbcolor.js", "http://canvg.googlecode.com/svn/trunk/canvg.js"]; | |
$.getScript(urls[0], function () { | |
$.getScript(urls[1], function () { | |
go(); | |
}); | |
}); | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment