Ansari Khalid Ansari Khalid - 3 months ago 20
Javascript Question

Uncaught TypeError: fn.call is not a function

I am using hightchart plugin in Yii2 application
now When I want call some event like click on series point the plugin shows an error Uncaught TypeError: fn.call is not a function please help me
My Js code for high chart is

Highcharts.setOptions([]);
new Highcharts.Chart({
"chart": {
"renderTo": "w0",
"type": "bar"
},
"credits": {
"enabled": false
},
"title": "Timeline content count monthly",
"xAxis": {
"categories": ["Aug 2016"],
"title": false
},
"yAxis": {
"min": 0,
"endOnTick": false,
"allowDecimals": false,
"title": {
"text": "Counts",
"align": "high"
},
"labels": {
"overflow": "justify"
}
},
"plotOptions": {
"bar": {
"dataLabels": {
"enabled": true
}
},
"series": {
"cursor": "pointer",
"point": {
"events": {
"click": "function(){console.log(1); }"
}
}
}
},
"series": [{
"name": "1st Week",
"data": [1]
}, {
"name": "2nd Week",
"data": [4]
}, {
"name": "3rd Week",
"data": [7]
}, {
"name": "4th Week",
"data": [0]
}, {
"name": "5th Week",
"data": [0]
}]


});

Here the data should be generated using an active dataprovider. I think this will not effect. May be it is a Js issue.
libraries are also included correctly. chart is also plotting perfect. only the problem is that whenever I am going to click on point it shows an error.



Thanks.

Answer

You have this:

"click": "function(){console.log(1); }"

Should be like this

"click": function() { 
  console.log(1); 
}