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

108
Visualizações
Chart js: bar width

I want to display data in chart js (version 3.7.1) with horizontal bar chart. Data are loading from backend. My problem is with widht of bar. When I have only a few records, bars are very thick.1 When I have a lot of records (for example 1000) bars are very narrow and are missing label.2 How can you see in images. I would like have still the same widht for bars and if is a lot of records enable scroll.

There is my code:

  createConfig(config: ChartConfigDto): ChartConfiguration {
    return {
      type: 'bar',
      data: {
        labels: config.labels,
        datasets:
            config.datasets.map((dataset, index) => ({
              label: dataset.label,
              backgroundColor: `${CHART_COLORS[index]}`,
              borderColor: `${CHART_COLORS[index]}`,
              data: dataset.data,
              barThickness: 'flex',
            }))
      },
      options: {
        indexAxis: 'y',
        plugins: {
          title: {
            display: true,
            text: 'Sites',
          },
          legend: {
            position: 'top',
          },
        },
        responsive: true,
        scales: {
          x: {
            stacked: true,
            position: 'top',
          },
          y: {
            stacked: true,
            grid: {
              display: false,
            },
          }
        },
      },
    }
  }
        <div class="modal-body">
          <canvas appChart [config]="config"></canvas>
        </div>

Thank you for help

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

0

There are two properties you can use to achieve.

  • barThickness
  • maxBarThickness

You can use maxBarThickness property in the dataset.

Here I'm attaching Stackblitz demo

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