From 0093dc0f7decc73eb86931ebe2b491a1bd7d9ac6 Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Tue, 9 Jan 2024 16:04:12 +0100 Subject: [PATCH 1/6] Returning file with a name based on request.body. --- lib/server/routes/export.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/routes/export.js b/lib/server/routes/export.js index 4b52a245..2dafdbe3 100644 --- a/lib/server/routes/export.js +++ b/lib/server/routes/export.js @@ -323,7 +323,7 @@ const exportHandler = (request, response) => { // Decide whether to download or not chart file if (!body.noDownload) { response.attachment( - `${request.params.filename || 'chart'}.${type || 'png'}` + `${request.body.filename || 'chart'}.${type || 'png'}` ); } From 9cbe50953ae3ff6820b5c3bfb954d07f03417491 Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Tue, 9 Jan 2024 16:12:38 +0100 Subject: [PATCH 2/6] Updated the readme. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 860da442..f3a171b4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Convert Highcharts.JS charts to static image files. ## Upgrade notes for V3.0 -V3 should be a drop in replacement for V2 in most cases. However, due to changing out the browser back-end part, the various tweaks related to process handling (e.g. worker counts and so on) may have different effects than they did previously. +V3 should be a drop in replacement for V2 in most cases. However, due to changing out the browser back-end part, the various tweaks related to process handling (e.g. worker counts and so on) may have different effects than they did previously. The API for when using the server as a node module has changed significantly, but a compatibility layer has been created to address this. It is however recommended to change to the new API described below, as the compatibility layer is likely to be deprecated at some point in the future. @@ -353,6 +353,7 @@ The server accepts the following arguments in a POST body: - `constr`: The constructor to use. Either `chart`, `stockChart`, `mapChart` or `ganttChart`. - `b64`: Bool, set to true to get base64 back instead of binary. - `noDownload`: Bool, set to true to not send attachment headers on the response. +- `filename`: If `noDownload == false`, the file will be downloaded with the `${filename}.${type}`. - `globalOptions`: A JSON object with options to be passed to `Highcharts.setOptions`. - `themeOptions`: A JSON object with options to be passed to `Highcharts.setOptions`. - `customCode`: Custom code to be called before chart initialization. Can be a function, a code that will be wrapped within a function or a filename with the js extension. From 285a76f3fd1c68273e514df2ec9a9b764cdbabdb Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Tue, 9 Jan 2024 16:18:50 +0100 Subject: [PATCH 3/6] Fixed readme grammar slips. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3a171b4..a1e792a3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ V3 should be a drop in replacement for V2 in most cases. However, due to changin The API for when using the server as a node module has changed significantly, but a compatibility layer has been created to address this. It is however recommended to change to the new API described below, as the compatibility layer is likely to be deprecated at some point in the future. -One important note is that the export server now requires `node v16.14.0` or highe +One important note is that the export server now requires `node v16.14.0` or higher. ## Changelog @@ -17,7 +17,7 @@ _Fixes and enhancements:_ - Replaced PhantomJS with Puppeteer - Updated the config handling system to optionally load JSON files, and improved environment var loading -- Rewrote the HC caching system: it's now easier to include custom modules/depdencey lists in your own deployments +- Rewrote the HC caching system: it's now easier to include custom modules/dependency lists in your own deployments - The install step no longer requires interaction when installing - Replaced the custom worker pool system with `tarn` - Error messages are now sent back to the client instead of being displayed in rasterized output @@ -276,7 +276,7 @@ Like previously mentioned, there are multiple ways to set and prioritize options The export server attaches event listeners to process.exit. This is to make sure that there are no memory leaks or zombie processes if the application is unexpectedly terminated. -Listeners are also attached to uncaught exceptions - if one appears, the entire pool is killed, and the application terminated. +Listeners are also attached to handle uncaught exceptions. If an exception occurs, the entire pool is terminated, and the application is shut down. If you do not want this behavior, start the server with `--listenToProcessExits 0`. @@ -353,7 +353,7 @@ The server accepts the following arguments in a POST body: - `constr`: The constructor to use. Either `chart`, `stockChart`, `mapChart` or `ganttChart`. - `b64`: Bool, set to true to get base64 back instead of binary. - `noDownload`: Bool, set to true to not send attachment headers on the response. -- `filename`: If `noDownload == false`, the file will be downloaded with the `${filename}.${type}`. +- `filename`: If `noDownload == false`, the file will be downloaded with the `${filename}.${type}` name. - `globalOptions`: A JSON object with options to be passed to `Highcharts.setOptions`. - `themeOptions`: A JSON object with options to be passed to `Highcharts.setOptions`. - `customCode`: Custom code to be called before chart initialization. Can be a function, a code that will be wrapped within a function or a filename with the js extension. From bb93cb8548ad3b6cbb3341126a7f97d89ece1d24 Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Wed, 10 Jan 2024 11:27:56 +0100 Subject: [PATCH 4/6] Added params.filename case. --- lib/server/routes/export.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/server/routes/export.js b/lib/server/routes/export.js index 2dafdbe3..4ccd8c25 100644 --- a/lib/server/routes/export.js +++ b/lib/server/routes/export.js @@ -323,7 +323,9 @@ const exportHandler = (request, response) => { // Decide whether to download or not chart file if (!body.noDownload) { response.attachment( - `${request.body.filename || 'chart'}.${type || 'png'}` + `${request.params.filename || request.body.filename || 'chart'}.${ + type || 'png' + }` ); } From 53ca5e95d19b2a2fa4fd669c187dd169d80d4085 Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Wed, 10 Jan 2024 15:10:04 +0100 Subject: [PATCH 5/6] Fixed #463, omit background only for png types. --- lib/export.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/export.js b/lib/export.js index c1fd3889..28fe5d57 100644 --- a/lib/export.js +++ b/lib/export.js @@ -61,10 +61,9 @@ const createImage = async (page, type, encoding, clip) => encoding, clip, - // #447 - always render on a transparent page - // this will not affect users who do not explicitly set - // chart.backgroundColor to a color with opacity lower than 1 - omitBackground: true + // #447, #463 - always render on a transparent page if + // the expected type format is PNG + omitBackground: type == 'png' }), new Promise((resolve, reject) => setTimeout(() => reject(new Error('Rasterization timeout')), 1500) From 10728fdcb9631cc5f9836791fe96c764931e642c Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Fri, 12 Jan 2024 09:49:37 +0100 Subject: [PATCH 6/6] Prep 3.0.5 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482b60b0..db462925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 3.0.5 + +- Fixed an issue with transparent backgrounds in PNG exports (#463) +- Fixed an issue with missing `filename` property (https://github.com/highcharts/highcharts/issues/20370) + # 3.0.4 - Fixed and issue with reading `resources.json` during exports diff --git a/package.json b/package.json index 052fc5f0..d69a7107 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "author": "Highsoft AS (http://www.highcharts.com/about)", "license": "MIT", "type": "module", - "version": "3.0.4", + "version": "3.0.5", "main": "dist/index.esm.js", "exports": { ".": {