如何在ES6中使用Highcharts.js

时间:2016-09-19 17:44:04

标签: javascript highcharts ecmascript-6

我已尽一切可能让Highcharts与Babel / Browserify / ES6导入一起使用。我得到了TypeError: (0 , _jquery2.default)(...).highcharts is not a function

在我的控制器中,我实例化了我的Chart类并调用了renderLineChart方法。我对我的内容的观点已经呈现。

我也测试了Jquery。没关系。

import $ from "jquery";
import Highcharts from "highcharts";
require('highcharts/modules/exporting')(Highcharts);

export default class Chart {
    constructor(content) {
        this._content = content;
    }

    renderLineChart() {
        alert($("#input").val());
        var chart1; // globally available
        $(this._content).highcharts({
            chart: {
                type: 'bar'
            },
            title: {
                text: 'Fruit Consumption'
            },
            xAxis: {
                categories: ['Apples', 'Bananas', 'Oranges']
            },
            yAxis: {
                title: {
                    text: 'Fruit eaten'
                }
            },
            series: [{
                name: 'Jane',
                data: [1, 0, 4]
            }, {
                name: 'John',
                data: [5, 7, 3]
            }],
        });
    }
}

0 个答案:

没有答案