如何在电子书摘录中使用highstock?

问题描述 投票:-2回答:1

这里是一个有效的代码示例,我创建了一个图

import $ from 'jquery';
import Highcharts from 'highcharts';

class test {
    constructor(){
        let chart = new Highcharts.chart('container', {
            chart: {
                animation: false
            },

            xAxis: {
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            },

            series: [{
                data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
            }]

        });
    }
}

现在我想做一个像https://jsfiddle.net/74vn5utd/的股票图表

但是我导入了它及其模块

import StockChart from 'highcharts/highstock';
import datahc from 'highcharts/modules/data';

加载模块之后

datahc(StockChart);

最后我将图表称为]

StockChart.chart('container', {


    rangeSelector: {
        selected: 1
    },

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

    series: [{
        name: 'AAPL',
        data: response.graph,
        tooltip: {
           valueDecimals: 2
        }
    }]
});

我有一个普通图形,而不是HighStock图形,我不明白,这是怎么回事?enter image description here

预先感谢

这是一个有效的代码示例,我从'jquery'创建了一个图形导入$;从“ highcharts”中导入Highcharts;类测试{builder(){let chart = new Highcharts.chart('...

javascript ecmascript-6 highcharts ecmascript-next
1个回答
2
投票

您仍然使用chart

© www.soinside.com 2019 - 2024. All rights reserved.