How to get a series identifier in Highcharts / Highstock

How to get Series ID? The API has only name and data, etc. But I do not have an identifier. How can I get an identifier from a series?

I use the following method to loop all the rows in a chart.

$(chart.series).each(function(i, serie){ // Want to get serie id }); 

EDIT:

I found that I can get the identifier using the following path. I'm not sure if this is the right way?

  $(chart.series).each(function(i, serie){ console.log(serie.options.id); }); 
+6
source share
2 answers

If you already know the series identifier, you can get a link to the series chart.get(ID)

If you want to view all series and list all series identifiers, do the following:

  $(chart.series).each(function(i, serie){console.log(serie.options.id)}) 

FIddle: http://jsfiddle.net/NaK9D/2/

+13
source

From the documentation:

Another way to refer to a series programmatically is to id. Add the identifier to the series configuration parameters and get the series object by chart.get (id).

It looks like you can do:

 $(chart.series).each(function(i, serie){ this.get(id); }); 
+2
source

Source: https://habr.com/ru/post/944668/


All Articles