in src/XAxisTitle.js [62:96]
static getMargin(props) {
const propsWithDefaults = defaults({}, props, XAxisTitle.defaultProps);
const { distance, position, rotate } = propsWithDefaults;
const placement =
propsWithDefaults.placement ||
(position === 'bottom' ? 'below' : 'above');
const zeroMargin = {
marginTop: 0,
marginBottom: 0,
marginLeft: 0,
marginRight: 0,
};
if (
(position === 'bottom' && placement === 'above') ||
(position === 'top' && placement === 'below')
)
return zeroMargin;
const title = propsWithDefaults.title || propsWithDefaults.children;
const style = defaults(
propsWithDefaults.style,
XAxisTitle.defaultProps.style,
);
const titleWithStyle = Object.assign({ text: title }, style);
const measured = measureText(titleWithStyle);
const marginValue =
distance +
Math.ceil(rotate ? measured.width.value : measured.height.value);
return position === 'bottom'
? { ...zeroMargin, marginBottom: marginValue }
: { ...zeroMargin, marginTop: marginValue };
}