Highcharts:代码工作中的小提琴,但不是我的Visual Studio(Highcharts

2019-11-02 04:42发布

我很新的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>

这是链接到我的小提琴:这是链接到我的小提琴:

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

Answer 1:

请看输出HTML和检查URL以highcharts.js是否正确。

如果没有,你应该调整

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

因此。 您的错误信息表明,这是情况并非如此。

从他们的CDN或者加载:

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

/卡斯帕



文章来源: Highcharts :the code works in Fiddle but not i Visual Studio