stimulus-components
stimulus-components copied to clipboard
Fix error in usage for Stimulus Chartjs
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.
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>
oops! Thank you for the fix!