0👍
In chart.js, there is very little legend configuration that can be done. You have basically mentioned all of them in your question. The reason this is so is because the default legend is rendered directly in the canvas object and its hard to parameterize this because the canvas API is not simple.
Despite this, the chart.js guys realized that we would want more flexibility and they have provided a mechanism to create/style your legend outside the scope of the chart. You can use the legendCallback
option to create a function that returns HTML/CSS for your legend and then call the .generateLegend()
prorotype method to render it.
Using this approach you can then place your legend anywhere on your HTML page and style it however you see fit with plain old HTML/CSS.
Here is an example that shows how to do what I am describing. I’m not that great with CSS so I’ll leave it to you to change the boxes to lines or whatever it is you are wanting.
One thing to note is that using an external legend breaks the ability for the legend to interact with the chart. You will have to build this in yourself. It can be a little complex depending on what you want to do, but nothing is impossible.
Here is another example of an external custom legend that shows a bit of chart interaction. Here we are highlighting the pie chart region on legend item mouseover. Refer to this other question (asked by you actually :D) to see how to manipulate the dataset toggling.
You should be able to combine all these examples to build the custom external legend of your dreams! Let me know if you have specific questions.