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

153
Visualizações
how to remove odd number from yaxes in chartjs using angular?

bar chart

html file

 <div class="mychart" >
                <canvas width="3" height="1"
                  *ngIf="loaded"
                  baseChart
                  [data]="barChartData"
                  [labels]="barChartLabels"
                  [options]="barChartOptions"
                  [legend]="barChartLegend"
                  [chartType]="barChartType"
                  [colors]="chartColors"
                >
                </canvas>
              </div>

.ts

barChartOptions: ChartOptions = {

    
    responsive: true,
    legend: {
      display: false,
    },

    scales: {
      yAxes: [
        {
          gridLines:{
            lineWidth:0
          },
          ticks: {
            callback: function (value: number, index, values) {
              return '$ ' + Intl.NumberFormat().format(value / 100000) + 'K';
            },
           
          },
          
        },
      ],
      xAxes: [{
     
          gridLines: {
            lineWidth: 0,
            
            
          },
          
        },
       
      ],
     
    },
  };

how to remove the odd number values in chartjs using anuglar 12 . I m using chartjs version 2.9.4 and ng-charts 2 .4.2 . I have attached the image for reference . I don't know which property to use to remove the stepvalues in Yaxes.

If reduce the size of the chart , chart became blurry

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can check in your ticks callback if the value is even and if so return what you have otherwise return an empty string:

barChartOptions: ChartOptions = {
  responsive: true,
  legend: {
    display: false,
  },
  scales: {
    yAxes: [{
      gridLines: {
        lineWidth: 0
      },
      ticks: {
        callback: function(value: number, index, values) {
          return value % 2 === 0 ? '$ ' + Intl.NumberFormat().format(value / 100000) + 'K' : '';
        },
      },
    }, ],
    xAxes: [{
        gridLines: {
          lineWidth: 0,
        },
      },
    ],
  },
};
about 4 years ago · Juan Pablo Isaza Relatório
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