2013-05-09 143 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'); 
    } 
});