javascript HighCharts 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20747999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:12:18  来源:igfitidea点击:

HighCharts is not defined

javascriptextjshighcharts

提问by salamey

Hi I have a simple MVC extjs application :

嗨,我有一个简单的 MVC extjs 应用程序:

My app.js :

我的 app.js :

Ext.Loader.setConfig({
    enabled: true,
    paths : {
        'Chart' : './Chart'
    }
});

Ext.require('Chart.ux.Highcharts');
Ext.require('Chart.ux.Highcharts.Serie');
Ext.require('Chart.ux.Highcharts.SplineSerie');

Ext.application({
    name: 'MyAppli',
    autoCreateViewport: true,
});

My Controller :

我的控制器:

showWindow: function () {

    var chartStore = this.getHighChartDataStore();
    var win = Ext.create('Ext.window.Window', {
        width : 800,
        height : 600,
        minHeight : 400,
        minWidth : 550,
        hidden : false,
        shadow : false,
        maximizable : true,
        collapsible: true,
        title : 'Highchart example',
        renderTo : Ext.getBody(),
        layout : 'fit',
        items : [{
            xtype : 'highchart',
            id : 'chart',
            defaultSerieType : 'spline',
            series : [{
                    dataIndex : 'yesterday',
                    name : 'Yesterday',
                    visible : true
                }, {
                    dataIndex : 'today',
                    name : 'Today',
                    visible : true
            }],
            store : chartStore,
            xField : 'time',
            chartConfig : {
                chart : {
                    type: 'spline',
                    marginRight : 130,
                    marginBottom : 120,
                    zoomType : 'x',
                    animation : {
                        duration : 1500,
                        easing : 'swing'
                    }
                },
                title : {
                    text : 'Standalone Highcharts for ExtJs 4 example',
                    x : -20 //center
                },
                subtitle : {
                    text : 'Random value',
                    x : -20
                },
                xAxis : [{
                    title : {
                        text : 'Time',
                        margin : 20
                    },
                    labels : {
                        rotation : 270,
                        y : 35
                    }
                }],
                yAxis : {
                    title : {
                        text : 'Value'
                    },
                    plotLines : [{
                        value : 0,
                        width : 1,
                        color : '#808080'
                    }]
                },
                plotOptions : {
                    series : {
                        animation : {
                            duration : 3000,
                            easing : 'swing'
                        }
                    }
                },       
                legend : {
                    layout : 'vertical',
                    align : 'right',
                    verticalAlign : 'top',
                    x : -10,
                    y : 100,
                    borderWidth : 0
                }
            }
        }]
    });
    win.show();
}

My problem is that the above function shows an empty window, while the console says : Uncaught ReferenceError: Highcharts is not definedin the file highcharts.json the function draw.

我的问题是上面的函数显示一个空窗口,而控制台说: Uncaught ReferenceError: Highcharts is not definedhighcharts.js函数的文件中draw

What am I doing wrong? I'm using Extjs 4.1 with the latest HighChart (taken from github).

我究竟做错了什么?我正在使用 Extjs 4.1 和最新的 HighChart(取自 github)。

My index.html :

我的 index.html :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">
        <link rel="stylesheet" type="text/css" href="app/view/combo_release.css">
        <script type="text/javascript" src="../extjs/ext-all.js"></script>
        <script type="text/javascript" src="app/app.js"></script>
        <script type="text/javascript" src="Chart/ux/highcharts.js"></script>
    </head>
    <body>
    </body>
</html>

回答by wergeld

Looks like you need to include jquery (or another supported js library) as well before you call the highcharts.js resource.

在调用 highcharts.js 资源之前,您似乎还需要包含 jquery(或其他支持的 js 库)。

回答by Archer

First you should include highcharts.jsbeforeyour app.js. Secondly looks like you should include highstock.jsprior to highcharts.jsalso.

首先,你应该包括highcharts.js之前app.js。其次看起来你也应该包括highstock.js之前highcharts.js