var data = [{
"x": [2, 0, 3, 2, 6, 2, 0, 1, 0, 0, 1, 0, 1, 0, 1, 7, 1, 1, 1, 0, 0],
"y": ["department name 1", "department name 2", "department name 3", "department name 4", "department name 5", "department name 6", "department name 7", "department name 8", "department name 9", "department name 10", "department name 11", "department name 12", "department name 13", "department name 14", "department name 15", "department name 16", "department name 17", "department name 18", "department name 19", "department name 20", "department name 21"],
"name": "Done",
"orientation": "h",
"marker": {
"color": "grey",
"width": 1
},
"type": "bar"
}, {
"x": [1, 0, 1, 5, 1, 1, 0, 7, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0],
"y": ["department name 1", "department name 2", "department name 3", "department name 4", "department name 5", "department name 6", "department name 7", "department name 8", "department name 9", "department name 10", "department name 11", "department name 12", "department name 13", "department name 14", "department name 15", "department name 16", "department name 17", "department name 18", "department name 19", "department name 20", "department name 21"],
"name": "Active",
"orientation": "h",
"marker": {
"color": "green",
"width": 1
},
"type": "bar"
}, {
"x": [2, 7, 7, 1, 13, 2, 15, 8, 5, 2, 12, 17, 2, 1, 0, 4, 6, 8, 2, 2, 14],
"y": ["department name 1", "department name 2", "department name 3", "department name 4", "department name 5", "department name 6", "department name 7", "department name 8", "department name 9", "department name 10", "department name 11", "department name 12", "department name 13", "department name 14", "department name 15", "department name 16", "department name 17", "department name 18", "department name 19", "department name 20", "department name 21"],
"name": "Remaining",
"orientation": "h",
"marker": {
"color": "yellow",
"width": 1
},
"type": "bar"
}]
Plotly.newPlot('plot', data, {
barmode: "stack",
title: 'Department stats',
xaxis: {
title: 'Sales'
},
yaxis: {
title: 'Departments',
dtick: 1
},
margin: {
l: 180
}
})
<div id="plot"></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>