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

301
Vistas
Chart.js: Why are there two y axes in my line graph?

I'm using chart.js to build a line graph. I can't figure out why there are two y-axes on my graph. I also tried changing the color of the tick labels to white but it isn't working either. Thanks for your help! Here's the preview of my code: https://codepen.io/suminohh/pen/vYROrEx

var xValues = ['6 am','8 am','10 am','12 pm','2 pm','4 pm','6 pm','8 pm','10 pm','12 am'];
        var yValues = [7,8,8,9,9,9,10,11,14,14,15];
        
        new Chart("myChart", {
          type: "line",
          data: {
            labels: xValues,
            datasets: [{
                fill: false,
              lineTension: 0,
              backgroundColor: "white",
              borderColor: "white",
              data: yValues,
            }]
          },
          options: {
            legend: {display: false},
            scales: {
                xAxes: [{ 
                    gridLines: {
                        color: 'white',
                        zeroLineColor: 'white',
                }}],
              yAxes: [
                {ticks: {
                    min: 6, 
                    max:16,
                },
                    color: 'white',
                },
                {gridLines: {
                        color: 'white', //give the needful color
                        zeroLineColor: 'white',
                    }},
            ],
            }
          }
        });

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because you have two axes defined for yAxes. Using proper indentation helps notice these:

yAxes: [
  {
    ticks: {
      min: 6, 
      max:16,
    },
    color: 'white',
  },
  {
    gridLines: {
      color: 'white', //give the needful color
      zeroLineColor: 'white',
    }
  },
],

See how after color you close the object and start another. Put them as one object and you won’t have two axes:

yAxes: [
  {
    ticks: {
      min: 6, 
      max:16,
    },
    color: 'white',
    gridLines: {
      color: 'white', //give the needful color
      zeroLineColor: 'white',
    }
  },
],
about 4 years ago · Juan Pablo Isaza Denunciar
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