2013-05-30 43 views
0

我需要使用Highcharts。我已经通过下面的代码尝试,但它给了我errorHighcharts - 找不到方法错误

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

highChart Hse:178 

(anonymous function) Hse:148 

b.Callbacks.c jquery-1.9.1.js:3 

b.Callbacks.p.fireWith jquery-1.9.1.js:3 
b.extend.ready jquery-1.9.1.js:3 

^h

 <div> 
    <span class="inlinesparkline"></span> 
    <span class="container"></span> 
</div> 

    <script type="text/javascript" src="@Url.Content("/Scripts/ext/highcharts.js")"></script> 
    <script type="text/javascript"> 
     //KPI Charts 
     $(function() { 
      highChart(); 

      function highChart() {      
       //Highcharts 
        $('.container').highcharts({ 
         chart: { 
          type: 'spline', 
          renderTo: 'container' 
         }, 
         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(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(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, 3, 18), 0.94], 
           [Date.UTC(1971, 3, 24), 0.9], 
           [Date.UTC(1971, 4, 16), 0.39], 
           [Date.UTC(1971, 4, 21), 0] 
          ] 
         }] 
        }); 

回答

0

问题是我使用了旧版本的highcharts.js!

现在,它的作品不错:)

+0

你可能想提一下,它是Highcharts的3.0版本,首先作为jQuery插件发布。 – pgraham

0

我adivice使用ID而不是类图。其次,您应该使用$(document).ready()$(function() {});加载DOM后生成图表。 http://jsfiddle.net/3WeZr/1/

+0

你能不能请参阅:http://stackoverflow.com/questions/16841450/highcharts-the-code-works-in-fiddle-but-not-i-visual-工作室 – Caveman

相关问题