Chartjs-How can I make bar charts symmetrical in chart.js?

0👍

Baha, é só colocar a propriedade scales stacked true

new Chart(document.getElementById("ProdFicha_Idade"), {
    type: 'horizontalBar',
    data: {
        labels: ["18-25", "25-30", "30-35", "35-40"],
        datasets: [
        {
            data: [1,2,3,4],
            label: "Male",
            backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
        },
        {
            data: [-1,-2,-3,-4],
            label: "Female",
            backgroundColor: ["blue", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"]
        }

            ]
    },
    options: {
            title: {
            display: true,
            text: 'Pyramide des ages'
        },
        scales: {
            xAxes: [{
                stacked: true,
            }],
            yAxes: [{
                stacked: true
            }]
        }
    }
})

Leave a comment