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

224
Visualizações
how to set all same height of bar in stacked-bar chartJS even though the numbers are not equal

https://jsfiddle.net/jsfLrc/krvodyx4/3/

I am using chart.js to create stacked bars. Now the height of each bar depends on their total numbers. I want to set all same height stacked bar even though the total numbers of each bar are not equal.

Is there any way to set it like this? result pic

below is the code I made now

  var ctx = document.getElementById('myChart').getContext('2d');
    var myChart = new Chart(ctx, {
        type: 'horizontalBar',
        data: {
            labels: ['F4A', 'F4B', 'F4C'],
            datasets: [{
                label: 'M',
                data: [47.62, 50.00, 100],
                backgroundColor: [
                    '#758C46',
                    '#758C46',
                    '#758C46',
                    
                ],
                borderColor: [
                    '#758C46',
                    '#758C46',
                    '#758C46',
                ],
                borderWidth: 1
            },{
                label: 'F',
                data: [52.38, 50.00, 0],
                backgroundColor: [
                    '#6BBCC0',
                    '#6BBCC0',
                    '#6BBCC0',
                ],
                borderColor: [
                  '#6BBCC0',
                  '#6BBCC0',
                  '#6BBCC0',
                ],
                borderWidth: 1
            }]
        },
        options: {
            indexAxis: 'y',
            scales: {
                xAxes: [{
                    stacked: true,
                    min: 0,
                    max: 100,
                    callback: function(value) {
                      return value + "%"
                    }
                }],
                yAxes: [{
                    ticks: {
                        beginAtZero: true,
                        max:100
                    },
                    stacked: true
                }]
            },
            legend: {
                display: true,
            },
            title: {
                display: true,
                fontColor: 'black',
                fontSize: '20'
            }
        }
    });
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