Reputation: 173
I have this in my drilldown event of highcharts which works right.
if (!e.seriesOptions) {
var s=e.point.name;
var chart = this,
drilldowns = {
'SAR': {
name: 'SAR',
data: yearData,
}
},
series = drilldowns[e.point.name];
chart.addSeriesAsDrilldown(e.point, series);
}
but when I replace string 'SAR' with e.point.name
if (!e.seriesOptions) {
var s=e.point.name;
var chart = this,
drilldowns = {
s: {
name: s,
data: yearData,
}
},
series = drilldowns[e.point.name];
chart.addSeriesAsDrilldown(e.point, series);
}
it does not show any drilldown data where in e.point.name has got string 'SAR' in it.
Upvotes: 0
Views: 35
Reputation: 3268
You cannot create a JS-Object like you intent to do:
var s = 'SAR',
drilldowns = {
s: {
name: s,
data: [],
}
}
will create an object drilldown
with the key s
instead of SAR
:
{s: {name: "SAR", data: [] }}
You can however use a String for a key with bracket notation:
var s = 'SAR',
drilldowns = {};
drilldowns[s] = {
name: s,
data: []
}
will create an drilldown-object with the right keys for you:
{SAR: {name: "SAR", data: []}}
Upvotes: 1