[BUG] Chart invisible when Legend too large
See original GitHub issueExpected Behavior
Imagine a Pie/Doughnut Chart with the following requirements:
- It has a Dataset of 100 Products
- Each Product is represented by a Legend Label (thus, 100 labels)
- The Chart resides within a medium div (say “col-lg-4” of Bootstrap)
It can be obvious that both the 6 generated columns with the Labels cannot fit to the div with the Chart. In my opinion, they should not.
Image presenting the Chart in a full-screen mode:

Current Behavior
When working with a Chart following the aforementioned requirements:
- The div of the chart (canvas) shows some of the Legend Labels (say the 60 last ones)
- The other Labels are hidden, rendered outside the canvas
- The Chart is nowhere to be seen, probably thrown out by the Labels
Image presenting the Chart in a smaller Div. Most elements are gone. All that is left are some of the Legend Labels:

Possible Solution
Add a scrollable overflow to the “box” that hosts the Legends?
Steps to Reproduce
- Create a medium div (any size will do, as long as it’s not a full-screen one)
<div class="row"><div class="col-lg-4"><div><div> - In the “col-lg-4” div, place a canvas for your Chart. Make it :
- Type = Pie/Doughnut
- Responsive = true
- Fullwidth = true (although “false” has the exact same behavior)
- Dataset = any array holding 100+ elements (e.g. array of {name, value})
- Labels = the “name” values of your array (so that you will have 100 labels)
Options Example:
options="{ 'responsive': true,'maintainAspectRatio':true,'transparencyEffects':true,'dataSetBorderWidth': 2, 'legend':{ 'display': true, 'fullWidth':true, 'position': 'right', 'labels':{'boxWidth':40, 'fontSize':12, 'fontStyle':'normal', 'fontColor':'#666', 'usePointStyle':false}}, 'pallette': ['#a694ff','#a59891','#98a7ad','#ea7d7d','#80d27a','#99b4f4','#fed444','#3f3f3f','#b6696c','#417d83','#ff9750']}"
When you run it, you will see that your div will only present some of the Legend Labels. All other Labels and the Chart will be cone.
Environment
- Chart.js version:2.2.1
- Browser name and version: Chrome & Mozilla
Issue Analytics
- State:
- Created 7 years ago
- Reactions:26
- Comments:22 (5 by maintainers)
Top Results From Across the Web
Chart.js legend took up too much spaces - Stack Overflow
I was having some problem with chart. js legend. The legend with long text took up too much spaces which resulting in the...
Read more >Pie Chart - Legend Value Problem in UI for ASP.NET AJAX
I believe the "-" label is related to this too. It might be a glitch caused by positioning and hiding these labels. I...
Read more >Show or hide a chart legend or data table - Microsoft Support
Select a chart and then select the plus sign to the top right. Point to Legend and select the arrow next to it....
Read more >Solved: Re: Legend not always showing on stacked bar chart...
When the legend is not visible, right click on that area of the sheet and select Properties... This will allow you to inspect...
Read more >Putting a Chart Legend On Its Own Page - Microsoft Excel Tips
Another option involves "hiding" the chart so the only visible item in Chart 2 is the legend. Click on Chart 2 so it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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

I have an idea. What if Chart.js’ constructor took in 2 canvases, 1 for the Chart itself, and the other for the Legend?
That way, one could control the sizing and positioning of each canvas separately.
For example, to solve the above problem, one could simply increase the height of the Legend canvas and wrap it with a scrollable
<div>(withoverflow: scroll;), without affecting the Chart canvas.This would also solve issue #1959 (size of Chart will not change if the height/width of the Legend changes).
How is this issue still opened? Is there no way to add a ‘min-height’ to the graph so it doesn’t shrink? That way the container will grow.