Can't create the legend box.
See original GitHub issueHi, Sorry, i know that the question has already been asked, but the answer is not clear to me. I am unable to reproduce something like this showing on the homepage of chart.js.
My Doughnut chart appears, but i don’t know how to add the legend. What do you mean here (https://github.com/nnnick/Chart.js/issues/428) by : “It’s up to you to put that HTML into your DOM somewhere and style it accordingly.” ?
window.onload = function(){
var ctx = document.getElementById("chart-area").getContext("2d");
window.myDoughnut = new Chart(ctx).Doughnut(doughnutData, {
responsive : true,
legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
});
myDoughnut.generateLegend();
};
What’s the problem ? Many thanks by the way 😃
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Add or edit a legend shape - Microsoft Support
Right-click the Legend shape, and then click Configure Legend. In the Configure Legend dialog box, do any of the following: Show or hide...
Read more >How to make a legend box bigger in excel - YouTube
Three hacks to increase the size of legend boxes in excel charts. ... try restarting your device. Your browser can't play this video....
Read more >Second legend box doesn't have correct symbols/markers
The problem is that I can't get the second legend box to associate the correct symbols with the sets. It just uses the...
Read more >How to Make a Legend Box Bigger in Excel
When you try to edit a legend using the Format Legend dialog box, Excel lets you change the legend's color, border and shadow,...
Read more >Can not make Legend border visible - MATLAB Answers
There is a box around the legend by default, and I cannot remember that ever not being the case. Does this happen from...
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 FreeTop 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
Top GitHub Comments
myDoughnut.generateLegend();
returns a string of HTML.You can then put that HTML somewhere on your page, then use CSS to style it.
So, if you had a div with the id
my-doughnut-legend
, you could do something like this:Hello, can you please resolve my issue as quickly as possible:- I am using canvas ng-2 doughnut chart
see my legends are currently coming in the shape as shown in the image but the need is to show the legends in the shape of a circle… so please help:-
in short I want
in the shape of circle