Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda