Hello, I love this plugin to be able to create charts. However, I’ve looked and cannot understand or find a way to use the legendCallback function to create an HTML legend.
Can you provide a link or an example of how to use the legendCallback
or chartInstance.generateLegend
? I have read the documentation and scoured the issues, but am not familiar on how to customize this code. What does the HTML legend look like?
@sensaetions The default

generateLegend()
function will generate a<ul class="0-legend">
for the chart, which you can style using thecss
descriptor[class="0-legend"]
. The0
is thechart.id
.In the following example you’ll find a chart with a HTML generated legend, which mimics the default legend.
CSS
JavaScript to create HTML legend
JavaScript legend onClick callback
default legendCallback
Chart.js/src/plugins/plugin.legend.js
Lines 67 to 80
in
ce1fc28
Edit: modified
legendClickCallback
to call the chart onClick-event.