Issue with Highcharts: Custom styling for legend isn't showing up when downloading the chart

I have created a custom legend for my chart using CSS, which displays correctly on the web. However, when I try to download the chart using the Print Chart option, the custom legend design does not appear in the downloaded document. All other download options work fine except for Print Chart. I have tried multiple solutions and even attempted to use a Highcharts JSFiddle example with a custom legend, but it still doesn't work as expected.

Highcharts.chart('container', {
exporting: {
    chartOptions: { 
        plotOptions: {
            series: {
                dataLabels: {
                    enabled: true
                }
            }
        }
    },
    fallbackToExportServer: false
},

title: {
    text: 'Offline export'
},
legend: {
        enabled: true,
            layout: 'vertical',
            backgroundColor: '#FFFFFF',
            align: 'right',
            useHTML: true,
            floating: false,
            verticalAlign: 'middle',
            x: -40,
            y: 10,
            itemMarginBottom: 20,
    labelFormatter: function () {

                return '<div><div style="padding-right: 5px;color: #666666;text-align:center;">Text 123<span style="padding-left: 5px;font-size: 12px;font-weight: 300;color: #999999;">(16.78%)</span></div>' +
                    '<div style="background:' + this.color + ';height:20px; width:120px;text-align:center;color:white;font-weight:300;font-size: 10px;line-height:20px;">'
                    + this.name + '</div></div>';
            }
},
subtitle: {
    text: 'Click the button to download as PNG, JPEG, SVG or PDF'
},

chart: {
    type: 'area'
},

xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
        'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},

series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 126.0, 148.5, 216.4, 194.1, 95.6, 54.4]
}]

});

If anyone has encountered a similar issue and found a solution, please guide me in resolving this problem.

Thank you

Answer №1

If you want to include HTML in your exported charts, you can try using the experimental allowHTML option. However, please note that this feature currently only works for SVG vector images unless you have an online export server set up. For more details, check out this link: https://github.com/highcharts/highcharts/issues/5985

exporting: {
    allowHTML: true,
    chartOptions: {...},
    //fallbackToExportServer: false
}

Check out a live demo here: https://jsfiddle.net/BlackLabel/2nvpfgyo/

For more information on the API Reference, visit: https://api.highcharts.com/highcharts/exporting.allowHTML

Answer №2

When using allowHTML, the download option works perfectly for everything except Print Chart. The legend does not render the same as it does for other download options in the case of Print Chart. I have attached a screenshot for reference.

View Print Chart Legend Issue

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Dimensions of date input field in Chrome browser on Windows

Having an issue with my code, I've created a fiddle to demonstrate the problem. You can view it here: http://jsfiddle.net/jmTqk/2/. The blue block blocks the spin button and datepicker dropdown link. It seems to only occur on Windows Chrome. I also c ...

Could you provide me with a demonstration of cross-domain functionality?

Similar Inquiry: Methods to bypass the same-origin policy Let's consider two domains for this example - "" and "". The first domain "" is generating data in JSON format as shown below: { "str_info": [ { "str_name": "Mark ...

I'm having trouble locating the documents I recently saved in my mongoose model

Here is my current challenge: I am populating a collection called "fruits" with some values. Once the data has been inserted, I want to use map to console.log each fruit individually. However, during the first attempt, instead of displaying a single fruit ...

What steps can be taken to modify the name that appears when one of the submenu options is chosen?

I am working on a nested menu that displays different organization lists. When a user selects an organization from the nested menu, I want the name of that organization to be displayed in the parent menu. Below is the code snippet that I have been using: ...

npm fails to install the dependencies listed in the package.json file

I've encountered an unusual issue. I'm attempting to install project dependencies on my server using a simple npm i command, but it's not generating a node_modules folder. I've already tried various suggested solutions such as running ...

Triggering a JQuery slider event on each individual slider handle within the range

Can events be triggered based on the movement of individual slider handles? I am curious because I need to dynamically update a datepicker depending on which handle is moved. However, I'm unsure if there is a way to: Specify an event for a specifi ...

Issues with Internet Explorer causing headaches with CSS :first-child selector malfunctioning, experiencing strange behavior when utilizing Google Web Fonts

Having some trouble with the layout of a website, particularly in IE. The issue can be observed at . When comparing the page in IE to Firefox, there are noticeable differences. Firstly, the top module on the right side is not displaying correctly in IE. I ...

What is preventing this JSON object from being parsed correctly?

Within my JavaScript file, The process of declaring and parsing the ajax response text is as follows: var subcats = JSON.parse(this.responseText); The actual responseText that needs to be parsed looks like this: {"presubcatId":"1","precatId":"1","presu ...

Is there a way to dynamically alter the heading color in Shopify liquid code?

After utilizing ChatGPT to review the code, I am uncertain if it is related to the color schemes. I am unsure of what I may be missing or doing incorrectly. While I can successfully alter the heading text, I am unable to change the color. Below is the code ...

Is there a way for me to add a clickable link within a tooltip?

In my title, I want to insert a clickable link like 'Link' or 'a'. The title is ready for any string you input. <MaterialSwitch title={CLICKABLE STRING HERE} /> ...

Is there a way to only allow the active video to play while disabling the others in this Vue 3 and Bootstrap 5 carousel?

I'm currently developing a Single Page Application (SPA) using Vue 3, TypeScript, and The Movie Database (TMDB). Additionally, I'm incorporating Bootstrap 5 for the UI. To showcase movie trailers on the movie details page, I've created the ...

The alignment of the footer navigation is off-center

I can't seem to get my footer navigation centered properly. I've tried adjusting the CSS but it's still not working as expected. .main-footer li { float: left; font-size: 0.85em; padding: 0 0.5em; margin-bottom: 0.5em; } .main-fo ...

Is the support for getPageSource().contains still available?

Using Selenium along with Javascript, I am attempting to utilize the command if(driver.getPageSource().contains("Yes!")) In order to check for the presence of Yes! anywhere on the page. However, I am receiving an error indicating that the comman ...

Can CSS be used for creating unique color combinations?

I am facing a challenge where I have two div elements with different transparent, colored backgrounds that overlap each other. My goal is to find a way to customize the color in the area where these elements overlap. For instance, if I blend red and blue ...

What is the process for calling app.vue methods from an ES6 module?

I am currently in the process of constructing a vuejs application using webpack, vuex, and vue-router. The organization of my project is as follows: [components] BlockingLayer.vue [store] index.js [restapi] index.js App.vue main.js Within App. ...

Tips for sending JSON information to refresh Highcharts Pie chart

Currently, I am attempting to utilize AJAX to send a year value to my server. The server will then retrieve information from a database regarding various countries' economies for that specific year. Subsequently, I intend to use this data to update th ...

Believing in false promises as true is what the statement assumes

I'm working on authentication for my app and encountered the following code: const ttt = currentUser.changedPasswordAfter(decoded.iat); console.log(ttt); if (ttt) { console.log('if thinks ttt is true'); The changedPasswordAfter fu ...

My Node.js environment is unable to recognize the Express object, causing issues with setting paths for my CSS and JavaScript files

Check out the following link for more information: http://expressjs.com/en/starter/static-files.html I'm currently utilizing sockets.io: const PORT = 3000; var objServer = require('express')(); var http = require('http').Server(o ...

What is the reason for create-react-app initializing twice?

After creating a react app using the command npx create-react-app, I encountered an issue: import React from 'react'; class Costly { constructor() { console.log('creating costly class'); } } function App() { const costlyRef ...

JSP not able to render CSS properly

Trying to apply some basic CSS to my JSP page. The JSP is located at WebContent > WEB-INF > pages > Login.jsp, while the CSS file is at WebContent > WEB-INF > css > Login.css. Below is my JSP code: <head> <link rel="stylesheet" ...