Highstock, error: Uncaught TypeError: w[(intermediate value)(intermediate value)(intermediate value)] is not a constructor
Highstock, error: Uncaught TypeError: w[(intermediate value)(intermediate value)(intermediate value)] is not a constructor
我正在尝试创建 highstock 图表,但出现以下错误:
error: Uncaught TypeError: w[(intermediate value)(intermediate
value)(intermediate value)] is not a constructor
我的 JSON 似乎有效,我的 javascript 也是,知道如何解决这个问题吗?
Javascript:
$.getJSON('<?php echo SITE_URL; ?>analytic/weekly_views_json', function(data)
{
// Create the chart
$('#container2').highcharts('StockChart', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Stock Price'
},
series: [{
name: 'AAPL Stock Price',
data: data,
type: 'spline',
}]
});
});
Json:
[[1420547368,1],[1423225768,1],[1425644968,1],[1428319768,1],[1430911768,1],[1433590168,1],[1452083368,1],[1454761768,1],[1457267368,1],[1458131368,1],[1459942168,1],[1494070168,1]]
第一个解法:
我有同样的错误,我在 HTML
代码中使用了 highchart
如下:
<head>
<script src="https://code.highcharts.com/highcharts.js"></script>
...
</head>
我的 js
代码是:
$('#container').highcharts('StockChart', {
...
});
关于highchart documention
,我们必须使用Highcharts.Chart
来创建新的highstock
。
所以我将代码更改为:
<head>
<script src="https://code.highcharts.com/highcharts.js"></script>
...
</head>
我的 js
代码是:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
...
});
此错误已解决!
第二种方案:
同样关于this documentation,如果你是运行 Chart和StockChart组合,你只需要加载highstock.js文件。
所以将我的代码更改为:
<head>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
...
</head>
我的 js
代码是:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
...
});
这对我有用
<script src="../lib/highcharts.js"/>
<script src="../lib/highcharts-more.js"/>
var chart = new Highcharts.Chart({
chart: {
renderTo: 'Temperature'
},
title: {
text: 'HighStock'
},
legend: {
enabled: true
},
xAxis: {
categories: ['1','2','3','4'],
title: {
text: 'day'
}
},
yAxis: {
title: {
text: 'values'
}
},
series: [{
name: 'temperature',
data: [
[5,30],[10,35],[15,40],[20,45]
],
}]
});
我正在尝试创建 highstock 图表,但出现以下错误:
error: Uncaught TypeError: w[(intermediate value)(intermediate value)(intermediate value)] is not a constructor
我的 JSON 似乎有效,我的 javascript 也是,知道如何解决这个问题吗?
Javascript:
$.getJSON('<?php echo SITE_URL; ?>analytic/weekly_views_json', function(data)
{
// Create the chart
$('#container2').highcharts('StockChart', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Stock Price'
},
series: [{
name: 'AAPL Stock Price',
data: data,
type: 'spline',
}]
});
});
Json:
[[1420547368,1],[1423225768,1],[1425644968,1],[1428319768,1],[1430911768,1],[1433590168,1],[1452083368,1],[1454761768,1],[1457267368,1],[1458131368,1],[1459942168,1],[1494070168,1]]
第一个解法:
我有同样的错误,我在 HTML
代码中使用了 highchart
如下:
<head>
<script src="https://code.highcharts.com/highcharts.js"></script>
...
</head>
我的 js
代码是:
$('#container').highcharts('StockChart', {
...
});
关于highchart documention
,我们必须使用Highcharts.Chart
来创建新的highstock
。
所以我将代码更改为:
<head>
<script src="https://code.highcharts.com/highcharts.js"></script>
...
</head>
我的 js
代码是:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
...
});
此错误已解决!
第二种方案:
同样关于this documentation,如果你是运行 Chart和StockChart组合,你只需要加载highstock.js文件。
所以将我的代码更改为:
<head>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
...
</head>
我的 js
代码是:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
...
});
这对我有用
<script src="../lib/highcharts.js"/>
<script src="../lib/highcharts-more.js"/>
var chart = new Highcharts.Chart({
chart: {
renderTo: 'Temperature'
},
title: {
text: 'HighStock'
},
legend: {
enabled: true
},
xAxis: {
categories: ['1','2','3','4'],
title: {
text: 'day'
}
},
yAxis: {
title: {
text: 'values'
}
},
series: [{
name: 'temperature',
data: [
[5,30],[10,35],[15,40],[20,45]
],
}]
});