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

393
Vistas
Why Ticks Not Working in Chart.js but everything is correct?
    var xValues = timeArray;

new Chart("myChart", 
{
  type: "line",
  data: 
  {
    labels: xValues,
    datasets: [{
      label: "Size",
      data: sizeArray,
      borderColor: "green",
      fill: false
    }]
  },
  options: 
  {
    legend: {display: false},
    scales: {
      xAxes: [{
        display: true,
        scaleLabel: {
            display: true,
            labelString: document.getElementById("label_text").innerHTML
        },
        ticks: {
            min: 0,
            max: 30,
            stepSize: 1
          }
    }],
     yAxes: [{
        display: true,
        scaleLabel: {
           display: true,
           labelString: "Size (no. of elements)"
       }
    }]
  }
  }
});

Everything else is working well.The data is properly plotted on the x axes But what I want is that my x axis to be linearly scaled. I have tried many things but still it isn't working. I am not able to find what am I missing?

Please help

Image of chart generated:

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

0

One quick solution is to change your chart type to scatter and set showLine to True. The scatter chart automatically uses linear axes for both x and y.

new Chart("myChart", 
{
  type: "scatter",
  data: 
  {
    labels: xValues,
    datasets: [{
      label: "Size",
      data: sizeArray,
      borderColor: "green",
      fill: false,
      showLine: true,
      tension: 0.15
    }]
  },...

Here is a DEMO

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