Wladimir Gramacho
Wladimir Gramacho

Reputation: 647

Customize Highcharts desc tag

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?

Upvotes: 2

Views: 176

Answers (2)

ppotaczek
ppotaczek

Reputation: 39099

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

Upvotes: 1

Vy Do
Vy Do

Reputation: 52516

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

Upvotes: 1

Related Questions