stimulus-components icon indicating copy to clipboard operation
stimulus-components copied to clipboard

Fix error in usage for Stimulus Chartjs

Open jclusso opened this issue 9 months ago • 1 comments

The install block has you register the controller as chartjs. I was going nuts trying to figure out what I was doing wrong when it didn't work until I realized this.

image

jclusso avatar May 02 '24 21:05 jclusso

hey @jclusso - thanks for this. I also struggled to get this working.

Since the controller is actually called Chartjs, it might make sense to have that be the registered controller name, and then just change the documentation to use data-chartjs- ...

The example has another error in that it does not include the type value which is also required. Here's what worked for me (and what I think the documentation should be updated to):

<canvas
  data-controller="chartjs"
  data-chartjs-type-value="line"
  data-chartjs-data-value="<%= @chart_data.to_json %>"
  data-chartjs-options-value="<%= @chart_options.to_json %>"
></canvas>

narath avatar May 07 '24 14:05 narath

oops! Thank you for the fix!

guillaumebriday avatar Jun 24 '24 09:06 guillaumebriday