Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPEG Output now has black background #463

Closed
paulo-raca opened this issue Jan 10, 2024 · 1 comment · Fixed by #464
Closed

JPEG Output now has black background #463

paulo-raca opened this issue Jan 10, 2024 · 1 comment · Fixed by #464
Assignees
Labels

Comments

@paulo-raca
Copy link

paulo-raca commented Jan 10, 2024

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.

chart (29)

This is the actual output from the default export server.
The black background can also be achieved with the offline exporter
chart (28)

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)
    });
@jszuminski
Copy link
Contributor

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants