Reputation: 9411
I use highcharts.js and I specified an id while creating series:
var series = [];
var key = "123";
var chartObject = {
type: 'line',
id: key,
name: "NAME"
data: [],
};
/// filling chartObject.data array
series.push(chartObject);
/// later this array of objects assigned as series property
/// in HighCharts.Chart() configuration
Later I needed to iterate over all series, that I do using cycle
// chart is my object made elsewhere with chart = new Highcharts.Chart({...});
var cs = chart.series;
angular.forEach(chart.series, function (s) {
// Here I want to know series ID to set visibility to true or false.
s.setVisible(false);
// debug
console.log(s.name); // WORKS OK
console.log(s.id);; // RETURNS UNDEFINED
});
How I can obtain 'id' from "series" object?
Upvotes: 2
Views: 2006
Reputation: 20536
Given your placement of the id
attribute, like this:
series = {
type: 'line',
id: 'myid',
name: 'my name',
data: [],
}
You can fetch it for any given series index x
like this:
chart.series[x].options.id
Upvotes: 3