From 8ba67b92c8956f109daf9af78743f654aec33e67 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Tue, 6 Aug 2024 15:15:11 +0200 Subject: [PATCH 1/5] Updated the Node.js Module example in the README, touch #563. --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index effeb48f..bf6045ba 100644 --- a/README.md +++ b/README.md @@ -568,20 +568,24 @@ const options = { } }; -// Initialize export settings with your chart's config -const exportSettings = exporter.setOptions(options); -// Must initialize exporting before being able to export charts -await exporter.initExport(exportSettings); +// Logic must be triggered in an asynchronous function +(async () => { + // Initialize export settings with your chart's config + const exportSettings = exporter.setOptions(options); -// Perform an export -await exporter.startExport(exportSettings, async (error, info) => { - // The export result is now in info - // It will be base64 encoded (info.data) + // Must initialize exporting before being able to export charts + await exporter.initExport(exportSettings); - // Kill the pool when we are done with it - await exporter.killPool(); -}); + // Perform an export + await exporter.startExport(exportSettings, async (error, info) => { + // The export result is now in info + // It will be base64 encoded (info.data) + + // Kill the pool when we are done with it + await exporter.killPool(); + }); +})(); ``` ## CommonJS support From 97ab0ca2d4762b83fa31b1992ae50cf318fd2ee3 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Tue, 6 Aug 2024 15:21:10 +0200 Subject: [PATCH 2/5] Small corrections, touch #563. --- README.md | 2 +- lib/highcharts.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf6045ba..7c2a83d8 100644 --- a/README.md +++ b/README.md @@ -580,7 +580,7 @@ const options = { // Perform an export await exporter.startExport(exportSettings, async (error, info) => { // The export result is now in info - // It will be base64 encoded (info.data) + // It will be base64 encoded (info.result) // Kill the pool when we are done with it await exporter.killPool(); diff --git a/lib/highcharts.js b/lib/highcharts.js index e82a2213..5e4b1df6 100644 --- a/lib/highcharts.js +++ b/lib/highcharts.js @@ -95,7 +95,7 @@ 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); From 8a7b94542f59b955236bbae5faf57e5ce1c7f0e2 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Tue, 6 Aug 2024 16:42:49 +0200 Subject: [PATCH 3/5] The instr and resources.json missing warning log corrections, touch #564. --- CHANGELOG.md | 8 ++++++++ lib/chart.js | 9 ++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9254b1bb..485bbc8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 4.0.3 + +_Fixes:_ + +- Fixed the warning message when the the default `resources.json` file is not found. +- Fixed the problem with the lack of the `instr` value, when the `options` is set instead. +- Corrected the `Node.js Module` example in the README. + # 4.0.2 _Hotfix_: diff --git a/lib/chart.js b/lib/chart.js index 47b28f8d..731d2c7a 100644 --- a/lib/chart.js +++ b/lib/chart.js @@ -97,6 +97,9 @@ export const startExport = async (settings, endCallback) => { try { log(4, '[chart] Attempting to export from a raw input.'); + // Use whichever one is available + exportOptions.instr = exportOptions.instr || exportOptions.options; + // Perform a direct inject when forced if (toBoolean(options.customLogic?.allowCodeExecution)) { return doStraightInject(options, endCallback); @@ -321,11 +324,7 @@ const doExport = async (options, chartJson, endCallback, svg) => { toBoolean(options.customLogic.allowFileResources) ); } catch (error) { - logWithStack( - 2, - error, - `[chart] Unable to load the default resources.json file.` - ); + log(2, `[chart] Unable to load the default resources.json file.`); } } } From 99af8db0e8d12caacf498064f927a5ed78e4a3b3 Mon Sep 17 00:00:00 2001 From: PawelDalek Date: Mon, 25 Nov 2024 17:26:50 +0100 Subject: [PATCH 4/5] Revert "564/resources-error" --- CHANGELOG.md | 8 -------- lib/chart.js | 9 +++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 485bbc8e..9254b1bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,3 @@ -# 4.0.3 - -_Fixes:_ - -- Fixed the warning message when the the default `resources.json` file is not found. -- Fixed the problem with the lack of the `instr` value, when the `options` is set instead. -- Corrected the `Node.js Module` example in the README. - # 4.0.2 _Hotfix_: diff --git a/lib/chart.js b/lib/chart.js index 731d2c7a..47b28f8d 100644 --- a/lib/chart.js +++ b/lib/chart.js @@ -97,9 +97,6 @@ export const startExport = async (settings, endCallback) => { try { log(4, '[chart] Attempting to export from a raw input.'); - // Use whichever one is available - exportOptions.instr = exportOptions.instr || exportOptions.options; - // Perform a direct inject when forced if (toBoolean(options.customLogic?.allowCodeExecution)) { return doStraightInject(options, endCallback); @@ -324,7 +321,11 @@ const doExport = async (options, chartJson, endCallback, svg) => { toBoolean(options.customLogic.allowFileResources) ); } catch (error) { - log(2, `[chart] Unable to load the default resources.json file.`); + logWithStack( + 2, + error, + `[chart] Unable to load the default resources.json file.` + ); } } } From c2e84bc588050b49cc22357ae5b0c32e342f8ff4 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Mon, 25 Nov 2024 17:38:49 +0100 Subject: [PATCH 5/5] Updated changelog, touch #563. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9254b1bb..55450e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 4.0.3 + +_Fixes:_ + +- Corrected the `Node.js Module` example in the README. + # 4.0.2 _Hotfix_: