2

I'm working with Highcharts on a React view. For accessibility and SEO reasons, I want to customize the desc tag, but I couldn't figure out how to do it looking in the documentation. Highcharts automatically inserts a desc tag like this:

<desc>Created with Highcharts 6.2.0</desc>

Is there any way to change this or is this hard-coded?

Vy Do
  • 46,709
  • 59
  • 215
  • 313

2 Answers2

1

You can use this solution:

(1) Create a fork from https://github.com/highcharts/highcharts

(2) Change the content what hard-coded from

<desc>Created with Highcharts 6.2.0</desc>

to

<desc>foo bar baa</desc>

(3) Install npm package from GitHub directly

npm install https://github.com/<username>/<repository>/tarball/master

like this https://stackoverflow.com/a/13302095/3728901

Vy Do
  • 46,709
  • 59
  • 215
  • 313
1

You can modify the <desc> tag by wrapping H.SVGRenderer.init method:

H.wrap(H.SVGRenderer.prototype, 'init', function(proceed) {
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    this.box.children[0].innerHTML = 'Custom description';

});

Live demo: http://jsfiddle.net/BlackLabel/42rqezns/

Docs: https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

ppotaczek
  • 36,341
  • 2
  • 14
  • 24