@@ -4,34 +4,37 @@ import { Progress } from 'reactstrap';
44
55import SimpleTooltip from './SimpleTooltip' ;
66
7- const ProgressBar = ( { magnitude, regression, color } ) => (
8- < SimpleTooltip
9- text = {
10- < Progress
11- multi
12- aria-label = { `Magnitude of difference based on lower is better. Metric: ${
13- regression ? 100 - magnitude : magnitude
14- } % regressed`}
15- >
16- { /* the % of the bars that are colored and transparent is based on the newIsBetter metric,
17- which determines whether the colored bar for magnitude is displayed on the left or right */ }
18- < div aria-hidden = "true" className = "progress w-100" >
19- < Progress
20- bar
21- value = { regression ? 100 - magnitude : magnitude }
22- color = { regression ? 'transparent' : color }
23- />
24- < Progress
25- bar
26- value = { regression ? magnitude : 100 - magnitude }
27- color = { regression ? color : 'transparent' }
28- />
29- </ div >
30- </ Progress >
31- }
32- tooltipText = "Relative magnitude of change (scale from 0 - 20%+)"
33- />
34- ) ;
7+ const ProgressBar = ( { magnitude, regression, color } ) => {
8+ const truncMag = regression
9+ ? ( Math . floor ( ( 100 - magnitude ) * 100 ) / 100 ) . toFixed ( 2 )
10+ : ( Math . floor ( magnitude * 100 ) / 100 ) . toFixed ( 2 ) ;
11+ return (
12+ < SimpleTooltip
13+ text = {
14+ < Progress
15+ multi
16+ aria-label = { `Lower is better. Metric: ${ truncMag } % regressed` }
17+ >
18+ { /* the % of the bars that are colored and transparent is based on the newIsBetter metric,
19+ which determines whether the colored bar for magnitude is displayed on the left or right */ }
20+ < div aria-hidden = "true" className = "progress w-100" >
21+ < Progress
22+ bar
23+ value = { regression ? 100 - magnitude : magnitude }
24+ color = { regression ? 'transparent' : color }
25+ />
26+ < Progress
27+ bar
28+ value = { regression ? magnitude : 100 - magnitude }
29+ color = { regression ? color : 'transparent' }
30+ />
31+ </ div >
32+ </ Progress >
33+ }
34+ tooltipText = "Relative magnitude of change (scale from 0 - 20%+)"
35+ />
36+ ) ;
37+ } ;
3538
3639ProgressBar . propTypes = {
3740 regression : PropTypes . bool . isRequired ,
0 commit comments