2013-05-09 209 views
0

javascript函數我想打電話從highcharts的plotoptions功能我想這樣的,但它的投擲的錯誤呼叫從highcharts plotOptions

plotOptions: { 
       series: { 
        events: { 
         legendItemClick: function(event) { 
         //iam trying to call a function here 
         sampletest(testArr); 

         } 
        } 
       } 
      } 

是這個possible..how調用從plotOptions另一個功能。

錯誤IAM越來越是

TypeError: d is undefined

+0

什麼錯誤? – 2013-05-09 12:59:36

+0

多數民衆贊成thats type error..it is TypeError:d is undefined – sasi 2013-05-09 13:00:41

+1

你可以發佈您的sampletest功能的代碼?錯誤可能在該函數中,而不是在legendItemClick函數中。 – SteveP 2013-05-09 13:48:34

回答

0

是的,你可以打電話從plotoptions事件的任何功能。 Highcharts允許我們這樣做。只是檢查功能

+0

感謝您的回覆罷工者。應該是該功能的範圍? – sasi 2013-05-09 13:26:52

+0

你是什麼意思_「檢查該功能的範圍」_? JS函數有其自己的範圍。如果你的意思不是:你爲什麼要檢查範圍?只需要「綁定」,如果需要的話 – 2013-05-10 00:37:02

0

的範圍請大家看一下例子http://jsfiddle.net/gF8Cf/3/

$(function() { 
    $('#container').highcharts({ 
     plotOptions: { 
      series: { 
       cursor: 'pointer', 
       events: { 
        click: function(event) { 
         custom(); 
        } 
       } 
      } 
     }, 

     series: [{ 
      data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]   
     }] 
    }); 

    function custom(){ 
     alert('aaaa'); 
    } 
});