HTML legend example
See original GitHub issueHello, 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?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:20 (7 by maintainers)
Top Results From Across the Web
HTML legend tag - W3Schools
Definition and Usage. The <legend> tag defines a caption for the <fieldset> element. Browser Support. Element.
Read more >The Field Set Legend element - HTML - MDN Web Docs
The <legend> HTML element represents a caption for the content of its parent <fieldset> . Try it. HTML Demo: <legend>. Reset. HTML CSS...
Read more >HTML <legend> Tag - GeeksforGeeks
The legend tag is used to define the title for the child contents. The legend elements are the parent element. This tag is...
Read more >HTML: <legend> tag - TechOnTheNet
The HTML <legend> tag is used to generate a caption for the <fieldset> tag when grouping related items in an HTML form. This...
Read more >HTML legend Tag - Javatpoint
HTML <legend> tag is used to insert a title or caption to its parent element such as <fieldset>. The <legend> element must be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
https://github.com/chartjs/Chart.js/blob/ce1fc28b743d518add5c89653108a287f6aa911d/src/plugins/plugin.legend.js#L67-L80
Edit: modified
legendClickCallback
to call the chart onClick-event.@MadalinaCi you can use a custom inline plugin for this: https://jsfiddle.net/Leelenaleee/drk3unhs/4/