From 87966a1b58b00a9ad90d8a275b6e2afec7729141 Mon Sep 17 00:00:00 2001 From: John Walker Date: Fri, 22 Apr 2016 14:59:28 +0100 Subject: [PATCH] Scaled bar width fix Add logic for calculating bar width when ticks are less than the data labels --- src/controllers/controller.bar.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 9574ed2e3..d0761f5b4 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -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); -- 2.47.2