Skip to content

Commit

Permalink
never round scales that would result in 0 bandwidth
Browse files Browse the repository at this point in the history
fixes #72
  • Loading branch information
Fil committed Dec 23, 2020
1 parent 5385b8d commit d55a599
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/scales.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ export function autoScaleRange(scales, dimensions) {
const {inset = 0} = scales.x;
const {width, marginLeft, marginRight} = dimensions;
scales.x.scale.range([marginLeft + inset, width - marginRight - inset]);
if (scales.x.scale.bandwidth && scales.x.scale.bandwidth() === 0) {
scales.x.scale.round(false);
}
}
if (scales.y && scales.y.range === undefined) {
const {inset = 0} = scales.y;
const {height, marginTop, marginBottom} = dimensions;
const range = [height - marginBottom - inset, marginTop + inset];
if (scales.y.type === "ordinal") range.reverse();
scales.y.scale.range(range);
if (scales.y.scale.bandwidth && scales.y.scale.bandwidth() === 0) {
scales.y.scale.round(false);
}
}
}

Expand Down

0 comments on commit d55a599

Please sign in to comment.