Search code examples
highchartsexport

Highcharts. How to export with different labels containing no HTML?


We use HTML content when we display our Highchart chart. But when we export, the resulting image contains the HTML markup. Is there a way we can supply labels without HTML to only export so the export will display similar to how it is rendered to the user in the browser?

Tried without any success, exporting.allowHTML: true We currently use labels.formatter to supply the labels with HTML markup


Solution

  • You can overwrite your formatter function only for exporting by using exporting.chartOptions.

    For example:

      exporting: {
        chartOptions: {
          yAxis: {
            labels: {
              useHTML: false,
              formatter: function() {
                return this.value;
              }
            }
          }
        }
      }
    

    Live demo: https://jsfiddle.net/BlackLabel/gwbx16yr/

    API Reference: https://api.highcharts.com/highcharts/exporting.chartOptions