victory-native
Version:
A charting library for React Native with a focus on performance and customization.
15 lines (14 loc) • 836 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBarGroupDimensionsForAxis = void 0;
const getBarGroupDimensionsForAxis = ({ axisStart, axisEnd, betweenGroupPadding, withinGroupPadding, groupCount, barsPerGroup, customBarWidth, barCount, }) => {
const groupWidth = ((1 - betweenGroupPadding) * (axisEnd - axisStart)) /
Math.max(1, groupCount);
const denominator = barCount && barCount > 0 ? barCount : Math.max(1, barsPerGroup);
const barWidth = customBarWidth !== undefined
? customBarWidth
: ((1 - withinGroupPadding) * groupWidth) / denominator;
const gapWidth = (groupWidth - barWidth * barsPerGroup) / Math.max(1, barsPerGroup - 1);
return { barWidth, groupWidth, gapWidth };
};
exports.getBarGroupDimensionsForAxis = getBarGroupDimensionsForAxis;