首页 > 解决方案 > 无法以角度显示多个高图?

问题描述

我正在使用 highcharts 以角度显示图形。在我的场景中,我需要显示多个带有随机数据的图表,并且以前的图表不应该反映新数据何时传递给新图表..我正在使用下面的代码

    runData = [320, 330,333,341,346,351];
    var create = function(id){
    $(document.body).append("<div id='c"+id.toString()+"'></div>");
    $('#c'+id.toString()).highcharts({
        chart: {
            type: 'spline',
            animation: Highcharts.svg, // don't animate in old IE
            marginRight: 10,
        },
        title: {
            text: 'Live random data'
        },
        xAxis: {
            type: 'datetime',
            tickPixelInterval: 150
        },
        yAxis: {
            title: {
                text: 'Value'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '</b><br/>' +
                    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) 
                   + '<br/>' +
                    Highcharts.numberFormat(this.y, 2);
            }
        },
        legend: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
        series: [{
            name: 'Random data',
            data: this.runData
        }]
    });
   }

create(1);
runData = [220, 320,333,321,326,251];
create('b');
runData = [120, 310,313,121,126,151];
create('c');

它在运行时显示错误,例如

     ERROR TypeError: 
     jquery__WEBPACK_IMPORTED_MODULE_3__(...).highcharts is not a 
      function
      at create (chatbox.component.ts:62)

标签: jqueryangularhighcharts

解决方案


推荐阅读