Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

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

Open
phpdvlp opened this issue Nov 25, 2021 · 0 comments
Open

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

phpdvlp opened this issue Nov 25, 2021 · 0 comments

Comments

@phpdvlp
Copy link

phpdvlp commented Nov 25, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant