mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Scaled bar width fix
Add logic for calculating bar width when ticks are less than the data labels
This commit is contained in:
parent
8e37b81378
commit
87966a1b58
@ -184,6 +184,12 @@ module.exports = function(Chart) {
|
||||
var categoryWidth = tickWidth * xScale.options.categoryPercentage;
|
||||
var categorySpacing = (tickWidth - (tickWidth * xScale.options.categoryPercentage)) / 2;
|
||||
var fullBarWidth = categoryWidth / datasetCount;
|
||||
|
||||
if (xScale.ticks.length !== this.chart.data.labels.length) {
|
||||
var perc = xScale.ticks.length / this.chart.data.labels.length;
|
||||
fullBarWidth = fullBarWidth * perc;
|
||||
}
|
||||
|
||||
var barWidth = fullBarWidth * xScale.options.barPercentage;
|
||||
var barSpacing = fullBarWidth - (fullBarWidth * xScale.options.barPercentage);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user