简体   繁体   English

HighStocks-在同一页面上添加2个图表

[英]HighStocks - Adding 2 charts on same page

Using HighStocks.js, I tried to add 2 identical graph on the same html page. 使用HighStocks.js,我尝试在同一html页面上添加2个相同的图形。

My code look like this: 我的代码如下所示:

function createGraph(placeHolderId, uniqueName, series) {
    $(placeHolderId).highcharts(uniqueName, {
            rangeSelector : { selected : 1 },
            series : series
    });
}

And I call it 2 times: 我称之为2次:

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. 在highstock.src.js的第1041行上。

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. 图表的名称必须为“ StockChart”,这是图表的类型,而不是变量名。

$(placeHolderId).highcharts('StockChart', {
        rangeSelector : { selected : 1 },
        series : series
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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