我是VS和Highcharts的新手。所以我需要你的帮助!
我在VS中运行代码时出现以下错误:
Uncaught TypeError: Object [object Object] has no method 'highcharts' Hse:95
(匿名函数)
在小提琴中工作正常! 有没有人知道如何解决这个问题?
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="@Url.Content("/Scripts/ext/sparkline.js")"></script>
<script type="text/javascript" src="@Url.Content("/Scripts/ext/highcharts.js")"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div>
<span class="inlinesparkline"></span>
<span class="dynamicbar" ></span>
<span class="container"></span>
</div>
</div>
</div>
<div class="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div>
<script type="text/javascript">
$(function () {
//Highcharts
$('.container').highcharts({
chart: {
type: 'spline'
},
title: {
text: 'Snow depth in the Vikjafjellet mountain, Norway'
},
subtitle: {
text: 'An example of irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
}
},
yAxis: {
title: {
text: 'Snow depth (m)'
},
min: 0
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + ' m';
}
},
series: [{
name: 'Winter 2007-2008',
data: [
[Date.UTC(1970, 9, 27), 0],
[Date.UTC(1970, 10, 10), 0.6],
[Date.UTC(1970, 10, 18), 0.7],
[Date.UTC(1970, 11, 2), 0.8],
[Date.UTC(1971, 0, 8), 0.78],
[Date.UTC(1971, 0, 12), 0.98],
[Date.UTC(1971, 0, 27), 1.84],
[Date.UTC(1971, 1, 10), 1.80],
[Date.UTC(1971, 1, 18), 1.80],
[Date.UTC(1971, 1, 24), 1.92],
[Date.UTC(1971, 2, 4), 2.49]
]
}, {
name: 'Winter 2008-2009',
data: [
[Date.UTC(1970, 9, 18), 0],
[Date.UTC(1970, 9, 26), 0.2],
[Date.UTC(1970, 11, 1), 0.47],
[Date.UTC(1970, 11, 11), 0.55],
[Date.UTC(1970, 11, 25), 1.38],
[Date.UTC(1971, 0, 8), 1.38],
[Date.UTC(1971, 3, 19), 1.6],
[Date.UTC(1971, 4, 25), 0.6],
[Date.UTC(1971, 4, 31), 0.35],
[Date.UTC(1971, 5, 7), 0]
]
}, {
name: 'Winter 2009-2010',
data: [
[Date.UTC(1971, 1, 23), 0.77],
[Date.UTC(1971, 2, 8), 0.77],
[Date.UTC(1971, 2, 14), 0.79],
[Date.UTC(1971, 2, 24), 0.86],
[Date.UTC(1971, 3, 4), 0.8],
[Date.UTC(1971, 3, 18), 0.94],
[Date.UTC(1971, 3, 24), 0.9],
[Date.UTC(1971, 4, 16), 0.39],
[Date.UTC(1971, 4, 21), 0]
]
}]
});
});
</script>
这是我小提琴的链接: 这是我小提琴的链接:
答案 0 :(得分:0)
请查看输出的html并检查highcharts.js的url是否正确。
如果不是,你应该调整
src="@Url.Content("/Scripts/ext/highcharts.js"
相应。您的错误消息表明情况并非如此。
或者从他们的cdn加载:
<script src="http://code.highcharts.com/highcharts.js"></script>
/卡斯帕