Open phpdvlp opened 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]); } }') ], ......
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]); } }') ], ......