2amigos / yii2-chartjs-widget

ChartJs Widget For Yii2
https://2amigos.us
Other
108 stars 69 forks source link

Can't able to add jsEvents (onClick) #52

Open phpdvlp opened 2 years ago

phpdvlp commented 2 years ago

I'm trying to add onClick function on chart but it throws error Setting unknown property: dosamigos\chartjs\ChartJs::jsVar

Here is code, ChartJs::widget([ 'type' => 'bar', 'jsVar' => 'BarChart', 'jsEvents' => [ 'onclick' => new JsExpression('function(e) { var activePoints = BarChart.getElementsAtEvent(e); if (activePoints !== undefined && activePoints[0] !== undefined && activePoints[0]._index !== undefined) { var selectedIndex = activePoints[0]._index; console.log(this.data.labels[selectedIndex]); } }') ], ......