aruizga aruizga - 1 year ago 311
Javascript Question

Horizontal stacked bar chart with chart.js

I am trying to find out if there is any plugin to do a horizontal stacked bar chart with chart.js

I see there are plugins for stacked bar charts and also for horizontal bar charts, but I didn't find one that combines both.

https://github.com/Regaddi/Chart.StackedBar.js

Anyone know how to achieve this?

Answer Source

I know this is a few months old, but I thought I'd add my answer for future generations.

I was able to do without without extra plugins. If you set the xAxes and yAxes to stacked:true under scales, you can create a stacked horizontal graph.

scales: {
     xAxes: [{
          stacked: true,
     }],
     yAxes: [{
          stacked: true
     }]
}

Here's a quick pen to show how I did it. http://codepen.io/jamiecalder/pen/NrROeB

Bonus: Includes code to show the values on the graph

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download