简体   繁体   中英

HighStocks - Adding 2 charts on same page

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 ?

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
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM