in src/YAxisTitle.js [63:96]
static getMargin(props) {
const propsWithDefault = defaults({}, props, YAxisTitle.defaultProps);
const { distance, position, rotate } = propsWithDefault;
const placement =
propsWithDefault.placement || (position === 'left' ? 'before' : 'after');
const zeroMargin = {
marginTop: 0,
marginBottom: 0,
marginLeft: 0,
marginRight: 0,
};
if (
(position === 'left' && placement === 'after') ||
(position === 'right' && placement === 'before')
)
return zeroMargin;
const title = propsWithDefault.title || propsWithDefault.children;
const style = defaults(
propsWithDefault.style,
YAxisTitle.defaultProps.style,
);
const titleWithStyle = Object.assign({ text: title }, style);
const measured = measureText(titleWithStyle);
const marginValue =
distance +
Math.ceil(rotate ? measured.height.value : measured.width.value);
return position === 'left'
? { ...zeroMargin, marginLeft: marginValue }
: { ...zeroMargin, marginRight: marginValue };
}