forked from regentmarkets-repo-archive/binary-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitStatsChart.js
More file actions
41 lines (37 loc) · 935 Bytes
/
Copy pathDigitStatsChart.js
File metadata and controls
41 lines (37 loc) · 935 Bytes
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
import React, { PureComponent } from 'react';
import { arrayMin, arrayMax } from 'binary-utils';
export default class DigitStatsChart extends PureComponent {
props: {
orientation: string,
stats: number[],
};
static defaultProps = {
orientation: 'horizontal',
stats: [],
};
render() {
const { stats, orientation } = this.props;
const min = arrayMin(stats);
const max = arrayMax(stats);
return (
<div className={'digit-stats-chart ' + orientation}>
{stats.map((x: number, i: number) => (
<div key={i} className="digit-stats-col">
<div
className="digit-stats-percentage"
>
{x.toFixed(2)}%
</div>
<div
className={'digit-stats-bar'
+ (x === max ? ' max' : '')
+ (x === min ? ' min' : '')}
style={{ transform: `scale(${x / max}, 1)` }}
/>
<div className="digit-stats-digit">{i}</div>
</div>
))}
</div>
);
}
}