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

110
Vistas
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 Respuestas
Responde la pregunta

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 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