File size: 1,307 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import Bar from './bar';
import XAxis from './x-axis';

const X_AXIS_LABEL_WIDTH = 42;

export default class ChartBarContainer extends PureComponent {
	static propTypes = {
		barClick: PropTypes.func,
		data: PropTypes.array,
		isPlaceholder: PropTypes.bool,
		isRtl: PropTypes.bool,
		isTouch: PropTypes.bool,
		width: PropTypes.number,
		yAxisMax: PropTypes.number,
		hideXAxis: PropTypes.bool,
	};

	static defaultProps = {
		isPlaceholder: false,
		hideXAxis: false,
	};

	render() {
		return (
			<>
				<div className="chart__bars">
					{ this.props.data.map( ( item, index ) => (
						<Bar
							index={ index }
							key={ index }
							isTouch={ this.props.isTouch }
							className={ item.className }
							clickHandler={ this.props.barClick }
							data={ item }
							max={ this.props.yAxisMax }
							count={ this.props.data.length }
							chartWidth={ this.props.chartWidth }
							setTooltip={ this.props.setTooltip }
						/>
					) ) }
				</div>
				{ ! this.props.isPlaceholder && ! this.props.hideXAxis && (
					<XAxis
						data={ this.props.data }
						labelWidth={ X_AXIS_LABEL_WIDTH }
						isRtl={ this.props.isRtl }
						chartWidth={ this.props.chartWidth }
					/>
				) }
			</>
		);
	}
}