in src/YAxis.js [185:254]
render() {
const {
width,
height,
position,
tickLength,
titleDistance,
labelDistance,
showTitle,
showLabels,
showTicks,
showGrid,
spacingTop,
spacingBottom,
spacingLeft,
spacingRight,
showLine,
lineStyle,
} = this.props;
const {
ticksProps,
gridProps,
labelsProps,
titleProps,
} = getAxisChildProps(this.props);
labelsProps.distance = labelDistance + (showTicks ? tickLength : 0);
if (showTitle && showLabels) {
// todo optimize so we don't generate labels twice
const labelsMargin = YAxisLabels.getMargin(labelsProps);
titleProps.distance =
titleDistance + labelsMargin[`margin${upperFirst(position)}`];
} else if (showTitle && showTicks) {
titleProps.distance = titleDistance + tickLength;
}
const axisLineX = position === 'left' ? -spacingLeft : width + spacingRight;
return (
<g
className="rct-chart-axis rct-chart-axis-y"
onMouseMove={this.handleOnMouseMove}
onMouseEnter={this.handleOnMouseEnter}
onMouseLeave={this.handleOnMouseLeave}
onClick={this.handleOnClick}
aria-hidden="true"
>
{showGrid ? <YGrid {...gridProps} /> : null}
{showTicks ? <YTicks {...ticksProps} /> : null}
{showLabels ? <YAxisLabels {...labelsProps} /> : null}
{showTitle ? <YAxisTitle {...titleProps} /> : null}
{showLine ? (
<line
className="rct-chart-axis-line rct-chart-axis-line-y"
x1={axisLineX}
x2={axisLineX}
y1={-spacingTop}
y2={height + spacingBottom}
style={lineStyle}
/>
) : null}
</g>
);
}