Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
Chart.js legend configuration options not working

I've used chart.js once a good while back for a little bit now and i'm trying to follow a video to get back into it on how to create a chart. I got stuck on the part where he's positioning the legend.

For some reason legend configuration doesn't work. Even when I add display: false, it doesn't budge from its original position. I've been looking for an error in my code to see if I just typed something wrong but I can't seem to find anything, can anyone help me with this?

Here's my code:

    <div class="container">
        <canvas id="myChart"></canvas>
    </div>

    <script>
        let myChart = document.getElementById('myChart').getContext('2d');
        let colorHex = ['#C0392B', '#884EA0', '#3498DB', '#138D75', '#F4D03F', '#34495E'];
        let labels = ['Boston', 'Worcester', 'Springfield', 'Lowell', 'Cambridge', 'New Bedfort']
        let percentages = [617594, 181045, 153060, 106519, 105162, 95072]

        let massPopChart = new Chart(myChart, {
            type:'pie', // bar, horizontalBar, pie, line, doughnut, radar, polarArea
            data:{
                labels: labels,
                datasets:[{
                    label: 'Skills',
                    data: percentages,
                    backgroundColor: colorHex,
                    hoverBorderWidth: 2,
                    hoverBorderColor: colorHex

                }]
            },
            options:{
              title: {
                display: true,
                text: 'Largest cities',
                fontSize: '25'
                },
                legend: {
                    display: false,
                     position:'bottom'
                }
            }
        });
    </script>
</body>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!