Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Superimposed bar chart

Open SuperPat45 opened this issue 11 months ago • 1 comments

Feature Proposal

I need a superimposed bar chart

The stacked bars are not suitable because bars are located one on top of the other, whereas I need that all bars starts at 0

The best I could get was using staked floating bars, but the problem is that the smallest bar is not always in front :

chart

{
  type: 'bar',
  data: {
    labels: ['Q1', 'Q2', 'Q3', 'Q4'],
    datasets: [{
      label: 'Users',
      backgroundColor: 'rgba(255, 0, 0, 1)',
      data: [[0, 2], [0, 1], [0, 1], [0, 1]]
    }, {
      label: 'Revenue',
      backgroundColor: 'rgba(0, 0, 255, 1)',
      data: [[0, 1], [0, 2],[0, 3], [0, 4]]
    }]
  },
    options: {
        scales: {
            xAxes: [{
                stacked: true
            }]
        }
    }
}

There is no way to force bar to be drawn after?

Possible Implementation

No response

SuperPat45 avatar Jan 13 '25 15:01 SuperPat45

You can only stack the x axis as you suggested:

options: {
  scales: {
    x: {
      stacked: true
    }
  }
}

LeeLenaleee avatar Jan 13 '25 16:01 LeeLenaleee