Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda