question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't create the legend box.

See original GitHub issue

6c7035ba-0624-11e4-89b9-8ce0ab35f241

Hi, 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:closed
  • Created 9 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nnnickcommented, Aug 6, 2014

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:

document.getElementById('my-doughnut-legend').innerHTML = myDoughnut.generateLegend();
0reactions
lakshyamathur1commented, Jun 6, 2018

Hello, can you please resolve my issue as quickly as possible:- I am using canvas ng-2 doughnut chart

image

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 image

in the shape of circle

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found