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.

How Align the Legend Items in Chart.js 2?

See original GitHub issue

I just need to align the Chart Legend so it don’t look too messy as the default shows, here is an example what I’m trying to achieve:

Chart.js Desire Legend Alignment

Please give some code suggestions: https://jsfiddle.net/holp/68wf75r8/

new Chart(document.getElementById("field-0"), { type: 'pie', data: { labels: ["Chat", "Prospeção", "Whatsapp", "Trial", "Site", "Telefone", "E-mail", "Evento"], datasets: [{ data: [700, 400, 200, 150, 80, 50, 20, 10], borderWidth: 2, hoverBorderWidth: 10, backgroundColor: pieColors, hoverBackgroundColor: pieColors, hoverBorderColor: pieColors, borderColor: pieColors }] }, options: { legend: { labels: { padding: 20 } } } });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

39reactions
mattdellcommented, Jan 19, 2017

Where?

24reactions
Yurko-Fedorivcommented, Mar 22, 2017

this http://stackoverflow.com/a/42957884/1779106 solved my alignment issue. I was changing labels alignment from bottom center to bottom left:

image

image

Really don’t know who would actually want it the original way 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Legend | Chart.js
Legend. The chart legend displays data about the datasets that are appearing on the chart. # Configuration options.
Read more >
Chart.js legend alignment left side - Stack Overflow
Your code is correct and you will be able to align the legend as following in the future: legend: { position: "top", align:...
Read more >
Legend Attribute - Salesforce Labs Github Organization
Attribute name Type Default display boolean true position string 'top' align string 'center'
Read more >
Tutorial on Chart Legend | CanvasJS JavaScript Charts
When we want Legend to appear for a dataSeries, we set showInLegend to true in that dataSeries, this makes the dataSeries to appear...
Read more >
[Solved]-How to align Chart JS "legend" on right-center-Chart.js
Chart js. · How to align Chart. · Chart js: how can I align the legend and the title · Angular-ChartJS align legend...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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