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/README.md b/README.md index 860da442..a1e792a3 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ 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. -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,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}` 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. 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) diff --git a/lib/server/routes/export.js b/lib/server/routes/export.js index 4b52a245..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.params.filename || 'chart'}.${type || 'png'}` + `${request.params.filename || request.body.filename || 'chart'}.${ + type || 'png' + }` ); } 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": { ".": {