Skip to content

Instantly share code, notes, and snippets.

@FarazPatankar
Last active January 8, 2017 19:17
Show Gist options
  • Select an option

  • Save FarazPatankar/4ae0a4f646678a3d0059975499fc73ea to your computer and use it in GitHub Desktop.

Select an option

Save FarazPatankar/4ae0a4f646678a3d0059975499fc73ea to your computer and use it in GitHub Desktop.
PhantomJS configuration to get the entire chart to render.
var webpage = require('webpage');
var system = require('system');
var input = system.args[1];
var output = system.args[2];
var page = webpage.create();
var capture = function (page, input, callback) {
page.open(input, function (status) {
console.log('Page Opened');
var interval, allDone;
interval = setInterval(function () {
console.log('Waiting...');
var allDone = page.evaluate(function () { return window.chartReady;});
if (allDone) {
console.log('Ready!');
clearInterval(interval);
callback();
}
}, 100);
});
};
capture(page, input, function (err) {
if (err) {
console.log(err);
} else {
page.render(output, {format: 'pdf'});
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment