Skip to content

Commit

Permalink
dataset.minSize --> scale.minBarLength
Browse files Browse the repository at this point in the history
  • Loading branch information
adube committed Sep 25, 2018
1 parent 07d135c commit dea3705
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/charts/bar.md
Expand Up @@ -77,7 +77,6 @@ Some properties can be specified as an array. If these are set to an array value
| `hoverBackgroundColor` | `Color/Color[]` | The fill colour of the bars when hovered.
| `hoverBorderColor` | `Color/Color[]` | The stroke colour of the bars when hovered.
| `hoverBorderWidth` | `Number/Number[]` | The stroke width of the bars when hovered.
| `minSize` | `Number` | The minimum size (height for vertical, width for horizontal) in pixels bars should be rendered.

### borderSkipped
This setting is used to avoid drawing the bar stroke at the base of the fill. In general, this does not need to be changed except when creating chart types that derive from a bar chart.
Expand All @@ -98,6 +97,7 @@ The bar chart defines the following configuration options. These options are mer
| `categoryPercentage` | `Number` | `0.8` | Percent (0-1) of the available width each category should be within the sample width. [more...](#barpercentage-vs-categorypercentage)
| `barThickness` | `Number/String` | | Manually set width of each bar in pixels. If set to `'flex'`, it computes "optimal" sample widths that globally arrange bars side by side. If not set (default), bars are equally sized based on the smallest interval. [more...](#barthickness)
| `maxBarThickness` | `Number` | | Set this to ensure that bars are not sized thicker than this.
| `minBarLength` | `Number` | | Set this to ensure that bars have a minimum length in pixels.
| `gridLines.offsetGridLines` | `Boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)

### barThickness
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/controller.bar.js
Expand Up @@ -385,7 +385,7 @@ module.exports = function(Chart) {
var isHorizontal = scale.isHorizontal();
var datasets = chart.data.datasets;
var value = scale.getRightValue(datasets[datasetIndex].data[index]);
var minSize = datasets[datasetIndex].minSize;
var minBarLength = scale.minBarLength;
var stacked = scale.options.stacked;
var stack = meta.stack;
var start = 0;
Expand All @@ -412,12 +412,12 @@ module.exports = function(Chart) {
head = scale.getPixelForValue(start + value);
size = (head - base) / 2;

if (minSize !== undefined && Math.abs(size) < minSize) {
size = minSize;
if (minBarLength !== undefined && Math.abs(size) < minBarLength) {
size = minBarLength;
if (value >= 0 && !isHorizontal || value < 0 && isHorizontal) {
head = base - minSize;
head = base - minBarLength;
} else {
head = base + minSize;
head = base + minBarLength;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/scales/scale.linear.js
Expand Up @@ -30,6 +30,8 @@ module.exports = function(Chart) {
return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
}

me.minBarLength = opts.minBarLength;

// First Calculate the range
me.min = null;
me.max = null;
Expand Down

0 comments on commit dea3705

Please sign in to comment.