highcharts / node-export-server

Highcharts Node.js export server
Other
356 stars 260 forks source link

Include external module to customCode #98

Closed tedcurrent closed 6 years ago

tedcurrent commented 6 years ago

I am adding customCode to the export options and I am extending the dateFormats by doing something like: customCode: 'function(){ Highcharts.dateFormats = { W: function(timestamp) { return "custom" } }; }'

This works just fine by formatting every "%W" label to "custom". Fine. However, I would like to format dates by using moment.js. Is there any way to add an external module to the customCode? Also, is there any way to do this in some other way?

So I would like to have something like:


customCode: 'function(){
  Highcharts.dateFormats = {
    W: function(timestamp) { return moment(timestamp).isoWeek().toString() }
  };
}'

Workaround with `new Date()` is not sufficient.
tedcurrent commented 6 years ago

This was solved by adding resources: "node_modules/moment/moment.js". Cheers!