I wrote a function which take an id of the link as a name of JSON dataset.
$('.link').click(function() {
var dataset = $(this).attr("id");
for (var i = 0; i < chart.series.length; i++) {
chart.series[i].setData(lata.dataset[i].data);
}
});
But in this case dataset is string and it doesn’t works. So how to get object from JSON file by string?
Use the
[]operator:foo['bar']andfoo.barare equivalent – except the fact that[]takes an expression and thus allows you to use e.g. a variable.