diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e0f635d..2ebff2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 4.0.2 + +_Fixes:_ + +- Made chart userOptions available within `customCode` as variable `options` [(#551)](https://github.com/highcharts/node-export-server/issues/551). + # 4.0.1 _Hotfix_: diff --git a/lib/highcharts.js b/lib/highcharts.js index 76afd976..e82a2213 100644 --- a/lib/highcharts.js +++ b/lib/highcharts.js @@ -41,11 +41,6 @@ export async function triggerExport(chartOptions, options, displayErrors) { // prevent from polluting other exports that can happen on the same page Highcharts.setOptionsObj = merge(false, {}, getOptions()); - // Trigger custom code - if (options.customLogic.customCode) { - new Function(options.customLogic.customCode)(); - } - // By default animation is disabled const chart = { animation: false @@ -100,6 +95,11 @@ export async function triggerExport(chartOptions, options, displayErrors) { const userOptions = options.export.strInj ? new Function(`return ${options.export.strInj}`)() : chartOptions; + + // Trigger custom code + if (options.customLogic.customCode) { + new Function('options', options.customLogic.customCode)(userOptions); + } // Merge the globalOptions, themeOptions, options from the wrapped // setOptions function and user options to create the final options object diff --git a/package.json b/package.json index 73fa2248..b9c9d642 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,15 @@ "require": "./dist/index.cjs" } }, - "files": ["dist", "bin", "templates", "install.js", "lib"], + "files": [ + "dist", + "bin", + "templates", + "install.js", + "lib", + "msg", + "public" + ], "repository": { "url": "https://github.com/highcharts/node-export-server", "type": "git"