Highcharts:代码在Fiddle中工作,但不是在Visual Studio [英] Highcharts :the code works in Fiddle but not i Visual Studio

查看:151
本文介绍了Highcharts:代码在Fiddle中工作,但不是在Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VS和Highcharts的新手。所以我需要你的帮助!



我在VS中运行我的代码时遇到以下错误:

 未捕获TypeError:Object [object Object]没有方法'highcharts'Hse:95 


$ b b

(匿名功能)



它在Fiddle中正常工作!
有没有人知道如何解决这个问题?

 < script src =// ajax.googleapis。 com / ajax / libs / jquery / 1.9.1 / jquery.min.js>< / script> 

< script type =text / javascriptsrc =@ Url.Content(/ Scripts / ext / sparkline.js)>< / script&
< script type =text / javascriptsrc =@ 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 =containerstyle =min-width:400px; height:400px; margin:0 auto>< / div&
< / div>

< script type =text / javascript>
$(function(){
// Highcharts
$('。container')。highcharts({
chart:{
type:'spline'

},
title:{
text:'挪威Vikjafjellet山的雪深
},
subtitle:{
text: 'Highcharts JS'
}中不规则时间数据的一个例子,
xAxis:{
type:'datetime',
dateTimeLabelFormats:{//不显示虚假年
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';
}
},

系列:[{
name:'Winter 2007-2008',
data:[
[Date。 UTC(1970,9,27),0],
[Date.UTC(1970,10,10),0.6],
[Date.UTC
[Date.UTC(1970,11,2),0.8],
[Date.UTC(1971,0,8),0.78],
[ ,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, 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],
[ 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>

这是指向我的小提琴的链接:
这是指向我的小提琴的链接:



http://jsfiddle.net/vbsvbs/LFXBd /
提前感谢!

解决方案

请检查输出的html并检查url highcharts.js是正确的。



如果没有,您应该调整

  src =@ Url.Content(/ Scripts / ext / highcharts.js

 

code>< script src =http://code.highcharts.com/highcharts.js>< / script>

/ Casper


I am very new to VS and Highcharts. So I need your help!

I get the error below when I run my code in VS:

Uncaught TypeError: Object [object Object] has no method 'highcharts' Hse:95

(anonymous function)

It is working fine in Fiddle! Does anyone has any idea how to fix this?

<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>

This is the link to my fiddle: and this is the link to my Fiddle:

http://jsfiddle.net/vbsvbs/LFXBd/ Thanks in advance!

解决方案

Please look at the outputted html and check whether the url to highcharts.js is correct.

If not you should adjust

src="@Url.Content("/Scripts/ext/highcharts.js" 

accordingly. Your error message suggests that this is not the case.

Alternatively load from their cdn:

<script src="http://code.highcharts.com/highcharts.js"></script>

/Casper

这篇关于Highcharts:代码在Fiddle中工作,但不是在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆