the name of the chart needs to be 'StockChart' which is the type of the chart and not a variable name.
$(placeHolderId).highcharts('StockChart', {
rangeSelector : { selected : 1 },
series : series
});
Question
Using HighStocks.js, I tried to add 2 identical graph on the same html page.
My code look like this:
function createGraph(placeHolderId, uniqueName, series) {
$(placeHolderId).highcharts(uniqueName, {
rangeSelector : { selected : 1 },
series : series
});
}
And I call it 2 times:
createGraph('#marketdata', 'StockChart', series1);
createGraph('#returns', 'Returns', series1);
Even if series are the same, 'market data' get created then for the second I get the error:
TypeError: Highcharts[constr] is not a constructor
chart = new Highcharts[constr](options, args[1]);
on line 1041 of highstock.src.js.
Why is the second failing ?
Solution
the name of the chart needs to be 'StockChart' which is the type of the chart and not a variable name.
$(placeHolderId).highcharts('StockChart', {
rangeSelector : { selected : 1 },
series : series
});