Skip to content

Instantly share code, notes, and snippets.

@anthonycoffey
Last active June 11, 2019 09:47
Show Gist options
  • Save anthonycoffey/2e0586561dafc0a43a4a88c97ab2f061 to your computer and use it in GitHub Desktop.
Save anthonycoffey/2e0586561dafc0a43a4a88c97ab2f061 to your computer and use it in GitHub Desktop.
Highcharts Export Server Node Module
const exporter = require('highcharts-export-server');
const chartExport = {
initPool: function (){
exporter.initPool({ // experiment with different values here to optimize performance
maxWorkers: 10,
initialWorkers: 1,
workLimit: 25,
timeoutThreshold: 2000,
queueSize: 3,
listenToProcessExits: 0 // set to 0 to skip attaching process.exit handlers
})
return false;
},
killPool: function(){
exporter.killPool();
return false;
},
export: function(exportSettings){
return new Promise((resolve, reject) => {
exporter.export(exportSettings, function(err, res){
if(err){
console.log(err);
return reject(err);
}
const data = res.data;
return resolve(data);
})
})
}
}
module.exports = chartExport;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment