简体   繁体   English

Highcharts.stockChart不是一个功能

[英]Highcharts.stockChart is not a function

I'm trying to make a graph using Hightcharts.js, but get an error 我正在尝试使用Hightcharts.js制作图表,但收到错误

TypeError: Highcharts.stockChart is not a function. TypeError:Highcharts.stockChart不是函数。

I install it using npm(package.json) 我使用npm(package.json)安装它

"highcharts": "^5.0.6"

Сall Сall

var Highcharts = require('highcharts');

And use 并使用

var options = {
    chart: {
        alignTicks: false,
        renderTo: 'container'
    },

    rangeSelector: {
        selected: 1
    },

    title: {
        text: 'AAPL Stock Volume'
    },

    series: [{
        type: 'column',
        name: 'AAPL Stock Volume',
        data: [],
        dataGrouping: {
            units: [[
                'week', // unit name
                [1] // allowed multiples
            ], [
                'month',
                [1, 2, 3, 4, 6]
            ]]
        }
    }];
};
var chart = Highcharts.stockChart(options);

Highstock is not a separate module, and belongs to Highcharts, I do not understand what could be the problem? Highstock不是一个单独的模块,属于Highcharts,我不明白可能是什么问题?

Highstock not a separate module, and belongs to Highcharts . Highstock不是一个单独的模块,属于Highcharts。 This is not true. 这不是真的。

But the reverse is. 但反过来是。 if you include Highstock then you need not to include Highcharts again. 如果你包括Highstock,那么你不需要再包括Highcharts。

As per the Highcharts documentations 根据Highcharts的文件

http://www.highcharts.com/docs/getting-started/installation http://www.highcharts.com/docs/getting-started/installation

Highcharts is already included in Highstock, so it is not necessary to load both. Highcharts已包含在Highstock中,因此无需加载两者。 The highstock.js file is included in the package. highstock.js文件包含在包中。

 $(document).ready(function(){ $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) { // Create the chart var dataObject = { rangeSelector: { selected: 1, inputEnabled: $('#container').width() > 480 }, title: { text: 'AAPL Stock Price' }, series: [{ name: 'AAPL', data: data, tooltip: { valueDecimals: 2 } }] , chart: { renderTo: 'container' } }; var chart = new Highcharts.stockChart(dataObject); }); }); 
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highcharts/5.0.6/css/highcharts.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/5.0.6/js/highstock.js"></script> <div id="container" style="height: 400px; min-width: 310px"></div> 

npm安装highcharts-angular ,然后

import * as Highcharts from 'highcharts/highstock';

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

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