File size: 553 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import PropTypes from 'prop-types';
import { PureComponent } from 'react';

export default class ChartLabel extends PureComponent {
	static propTypes = {
		isRtl: PropTypes.bool,
		label: PropTypes.string.isRequired,
		width: PropTypes.number.isRequired,
		x: PropTypes.number.isRequired,
	};

	render() {
		const labelStyle = {
			[ this.props.isRtl ? 'right' : 'left' ]: this.props.x + 'px',
			width: this.props.width + 'px',
		};

		return (
			<div className="chart__x-axis-label" style={ labelStyle }>
				{ this.props.label }
			</div>
		);
	}
}