Skip to content

Commit 7a2ad0e

Browse files
authored
Merge pull request #551 from level420/fix-issue-548-options-in-customcode-context
Make userOptions of the chart available within customCode context
2 parents 79bef50 + ca80ae0 commit 7a2ad0e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 4.0.2
2+
3+
_Fixes:_
4+
5+
- Made chart userOptions available within `customCode` as variable `options` [(#551)](https://github.com/highcharts/node-export-server/issues/551).
6+
17
# 4.0.1
28

39
_Hotfix_:

lib/highcharts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ export async function triggerExport(chartOptions, options, displayErrors) {
4141
// prevent from polluting other exports that can happen on the same page
4242
Highcharts.setOptionsObj = merge(false, {}, getOptions());
4343

44-
// Trigger custom code
45-
if (options.customLogic.customCode) {
46-
new Function(options.customLogic.customCode)();
47-
}
48-
4944
// By default animation is disabled
5045
const chart = {
5146
animation: false
@@ -100,6 +95,11 @@ export async function triggerExport(chartOptions, options, displayErrors) {
10095
const userOptions = options.export.strInj
10196
? new Function(`return ${options.export.strInj}`)()
10297
: chartOptions;
98+
99+
// Trigger custom code
100+
if (options.customLogic.customCode) {
101+
new Function('options', options.customLogic.customCode)(userOptions);
102+
}
103103

104104
// Merge the globalOptions, themeOptions, options from the wrapped
105105
// setOptions function and user options to create the final options object

0 commit comments

Comments
 (0)