2👍
You may be looking after the offset option
Example with multiple datasets:
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['A', 'B', 'C', 'D', 'E'],
datasets: [{
label: 'somelabel',
xAxisID:'bar-x-axis1',
data: [40, 50, 30, 12, 52]
},
{
// ... other dataset...
}]
},
options:{
scales:{
xAxes:[
{
id:'bar-x-axis1',
type:'category',
offset: true // <== that one!
},
{
// ... other X axis...
}]
}
}
});
- [Chartjs]-Updating chartJS with dynamic data
- [Chartjs]-Resize the width and height of the ng2-charts
0👍
Make your bar graph contains proper groupSpace, barSpace, barWidth
(groupSpace * barSpace) * n + groupSpace = 1
Make this equation is correct, given n is the number of bars
Source:stackexchange.com