简体   繁体   中英

how to change the legends of highcharts to custom name?

I am new to highcharts and I want to change the text of the legends of the charts with the text that i have in an array. I have an array of "name" and i want it to be the text of the legends. Is there any way to solve my problem?

The jsfiddle link is given in the comment below. Thanks in Advance

To change series name displayed in legend, but not name of a series, then you could use labelFormatter (as Sebastian suggested). If series are indexed the same as your name array then you could access series _i property and use it to get proper name from name array.

var name = ["a","b","c","d"];
...
        legend: {
            labelFormatter: function () {
                return name[this._i];
            }
...

Example: http://jsfiddle.net/3ks9cxvn/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM