ankane / chartkick

Create beautiful JavaScript charts with one line of Ruby
https://chartkick.com
MIT License
6.33k stars 565 forks source link

More formatting options on chart legends #593

Closed elarue53078 closed 2 years ago

elarue53078 commented 2 years ago

In discussing chartkick implementations, our team noticed certain ways we'd like to format the legend that we seem to be unable to do:

1) The legend seems to put all the legend objects on one line; we would like the option to put each element on its own line. 2) In connection with the above, we would like to left-align the legend elements. Currently only the default center alignment appears to be available. 3) The color keys are currently rectangles. We would like to change this to squares.

ankane commented 2 years ago

Hey @elarue53078, you can use library option to make make customizations that the underlying charting library supports.

bhanubhakta commented 9 months ago

@ankane I am using the options like this:

library: { legend: { display: false, position: 'bottom', labels: { usePointStyle: true, boxWidth: 6 } } }

Also tried:

library: { options: { plugins: { legend: { display: true, position: 'bottom', labels: { usePointStyle: true, boxWidth: 6 } } } } }

Also tried:

library: { options: { legend: { display: true, position: 'bottom', labels: { usePointStyle: true, boxWidth: 6 } } } }

None worked. I am using Chart.js and it has the options I provided above.

Am I doing something wrong?

maxlein commented 6 months ago

This is also not working for me