JPEG Output now has black background
paulo-raca opened this issue · 1 comments
Expected behaviour
My chart has transparent background, which makes it look nice over different light backgrounds (I use light grayscale gradients on my website).
Highcharts.setOptions({
chart: {
backgroundColor:'rgba(255, 255, 255, 0)',
},
})
When exporting to JPEG I expect it to have a white background.
Actual behaviour
Starting recently, Highchart's export server now produces JPEG images with black background
This is the expected output. Highchart's default export server used to produce this until recently.
Running node-export-server locally currently results in an image with white background.
This is the actual output from the default export server.
The black background can also be achieved with the offline exporter
Reproduction steps
Here is a jsfiddle that reproduces the issue:
https://jsfiddle.net/jteu92fm/5/
Workaround
I have successfully worked around it by hooking exportChart
to set the background color to white if the format is JPEG (I want it to remain transparent on other formats)
Highcharts.wrap(Highcharts.Chart.prototype, 'exportChart', function(proceed, exportingOptions, chartOptions) {
if (exportingOptions && exportingOptions.type == "image/jpeg") {
chartOptions = chartOptions || {}
chartOptions.chart = chartOptions.chart || {}
chartOptions.chart.backgroundColor = 'rgb(255, 255, 255)'
}
return proceed.call(this, exportingOptions, chartOptions)
});
Thanks for reporting and your neat workaround @paulo-raca! We really appreciate it!
I've already created a pull request for this issue: #464 and it should be merged and deployed with our next minor release this week.
So, hopefully, next week you will not have to use your workaround anymore :)