Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option OnClick event #79

Open
g-trema opened this issue Nov 20, 2018 · 1 comment
Open

Option OnClick event #79

g-trema opened this issue Nov 20, 2018 · 1 comment

Comments

@g-trema
Copy link

g-trema commented Nov 20, 2018

Hi!
Thank you for this laravel package!

I have a chart built with an onClick option like this one:

onClick:function(c,i){
  e = i[0];
  var id = this.data.labels[e._index];
  var page = "index.php?product=" +id;
  document.location.href=page;
}

How can I pass this option through the controller ?
I tried some things, but nothing works.

Thank you for your help!

Edit:
Same question with the tooltips option:

tooltips: {
   callbacks: {
       label: function(item, data) {
              var label = data.datasets[item.datasetIndex].label;
              var value = data.datasets[item.datasetIndex].data[item.index];
              if (value === 0.08) {
                     value = 0;
              }

               return label + ': ' + value;
              }
       }
}
@g-trema
Copy link
Author

g-trema commented Nov 20, 2018

... it was a stupid question...
Solution: I use the optionsRaw function.

$options = "{onClick:function(c,i){
                    	  var e = i[0];
                    	  var id= this.data.labels[e._index];
                    	  alert(montre);
 }}";

and in my variable $chartjs :
->optionsRaw($options)

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

No branches or pull requests

1 participant