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

180
Visualizações
How can I remove specific ticks and rearrange the chart? Please the attached image

I am new to ChartJS and trying to tweak the chart. I have removed specific y-axis ticks using callback function but getting space between the remaining ticks but I want to rearrange the chart with same width between ticks.

Expected result

enter image description here

Here is the sample fiddle which I tried.

Can someone help me?

var data = [{
  x: 0,
  y: 10
}, {
  x: 2,
  y: 10
}, {
  x: 6,
  y: 10
}, {
  x: 10,
  y: 50
}];

var labels_x = [1.6666666666666665, 9.666666666666666, 17.666666666666668, 25.666666666666668, 33.666666666666664, 41.666666666666664, 49.666666666666664, 57.666666666666664] // note computed values not integer
var labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Mon']

var options = {
  type: 'line',
  data: {
    datasets: [{
      data: data
    }, ]
  },
  options: {
    scales: {
      yAxes: [{
        ticks: {
          min: 0,
          callback(value, index) {
            if (value != 20 && value != 25) {
              return value;
            }
            console.log("val::::::::", value)
          }
        }
      }],
      xAxes: [{
        type: 'linear',
        ticks: {
          min: 0,
          max: 61,
          autoSkip: false,
          callback(value, index) {
            return labels[index];
          }
        },
        afterBuildTicks(scale) {
          return labels_x;
        }
      }]
    }
  }
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
canvas {
  background-color: #eee;
}
<body>
  <canvas id="chartJSContainer" width="600" height="300"></canvas>
</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>

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