in src/MarkerLineChart.js [131:192]
static getSpacing(props) {
const tickType = getTickType(props);
// no spacing for rangeValue marker charts since line start and end are set explicitly
if (tickType === 'RangeValue')
return {
spacingTop: 0,
spacingRight: 0,
spacingBottom: 0,
spacingLeft: 0,
};
const {
lineLength,
horizontal,
data,
xDomain,
yDomain,
xScale,
yScale,
x,
y,
} = props;
const P = lineLength / 2; // padding
const markDomain = horizontal ? yDomain : xDomain;
const markScale = horizontal ? yScale : xScale;
const markAccessor = horizontal ? makeAccessor2(y) : makeAccessor2(x);
const markDataDomain = domainFromData(data, markAccessor);
// find the edges of the tick domain, and map them through the scale function
const [domainHead, domainTail] = [first(markDomain), last(markDomain)]
.map(markScale)
.sort(); // sort the pixel values return by the domain extents
// find the edges of the data domain, and map them through the scale function
const [dataDomainHead, dataDomainTail] = [
first(markDataDomain),
last(markDataDomain),
]
.map(markScale)
.sort(); // sort the pixel values return by the domain extents
// find the necessary spacing (based on bar width) to push the bars completely inside the tick domain
const [spacingTail, spacingHead] = [
clamp(P - (domainTail - dataDomainTail), 0, P),
clamp(P - (dataDomainHead - domainHead), 0, P),
];
if (horizontal) {
return {
spacingTop: spacingHead,
spacingBottom: spacingTail,
spacingLeft: 0,
spacingRight: 0,
};
}
return {
spacingTop: 0,
spacingBottom: 0,
spacingLeft: spacingHead,
spacingRight: spacingTail,
};
}