0

我对 VS 和 Highcharts 很陌生。所以我需要你的帮助!

在 VS 中运行代码时出现以下错误:

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

(匿名函数)

它在 Fiddle 中运行良好!有谁知道如何解决这个问题?

<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/ 提前致谢!

4

1 回答 1

0

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

如果不是你应该调整

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

因此。您的错误消息表明情况并非如此。

或者从他们的 CDN 加载:

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

/卡斯帕

于 2014-09-19T17:37:21.967 回答