Skip to content

Commit

Permalink
Merge pull request #551 from level420/fix-issue-548-options-in-custom…
Browse files Browse the repository at this point in the history
…code-context

Make userOptions of the chart available within customCode context
  • Loading branch information
PaulDalek authored Aug 5, 2024
2 parents 79bef50 + ca80ae0 commit 7a2ad0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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_:
Expand Down
10 changes: 5 additions & 5 deletions lib/highcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7a2ad0e

Please sign in to comment.