@@ -4,23 +4,21 @@ import ReactHover, { Trigger, Hover } from 'react-hover';
4
4
import { OptionsCursorTrueWithMargin } from '../../../FrontendTypes' ;
5
5
import { setCurrentTabInApp } from '../../../slices/mainSlice' ;
6
6
import { useDispatch } from 'react-redux' ;
7
- /*
8
- Used to render a single radial graph on the 'Web Metrics' tab
9
- */
10
7
11
8
const radialGraph = ( props ) => {
12
9
const dispatch = useDispatch ( ) ;
13
10
const state = {
14
- series : [ props . series ] , // series appears to be the scale at which data is displayed based on the type of webMetrics measured.
11
+ series : [ props . series ] ,
15
12
options : {
16
- colors : [ props . color ] , // color of the webmetrics performance bar from 'StateRoute'
13
+ colors : [ props . color ] ,
17
14
chart : {
18
15
height : 100 ,
19
16
width : 100 ,
20
17
type : 'radialBar' ,
21
18
toolbar : {
22
19
show : false ,
23
20
} ,
21
+ foreColor : 'var(--text-primary)' ,
24
22
} ,
25
23
plotOptions : {
26
24
radialBar : {
@@ -48,29 +46,21 @@ const radialGraph = (props) => {
48
46
} ,
49
47
} ,
50
48
track : {
51
- background : '#161617 ' ,
52
- strokeWidth : '3 %' ,
49
+ background : 'var(--border-color-dark) ' ,
50
+ strokeWidth : '10 %' ,
53
51
margin : 0 ,
54
- dropShadow : {
55
- enabled : true ,
56
- top : - 3 ,
57
- left : 0 ,
58
- blur : 4 ,
59
- opacity : 0.35 ,
60
- } ,
61
52
} ,
62
-
63
53
dataLabels : {
64
54
show : true ,
65
55
name : {
66
56
offsetY : - 10 ,
67
57
show : true ,
68
- color : '#161617 ' ,
58
+ color : 'var(--text-primary) ' ,
69
59
fontSize : '24px' ,
70
60
} ,
71
61
value : {
72
62
formatter : props . formatted ,
73
- color : '#3c6e71 ' ,
63
+ color : 'var(--color-primary) ' ,
74
64
fontSize : '16px' ,
75
65
show : true ,
76
66
} ,
@@ -97,9 +87,22 @@ const radialGraph = (props) => {
97
87
} ;
98
88
99
89
useEffect ( ( ) => {
100
- dispatch ( setCurrentTabInApp ( 'webmetrics' ) ) ; // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'webmetrics' to facilitate render.
90
+ dispatch ( setCurrentTabInApp ( 'webmetrics' ) ) ;
101
91
} , [ ] ) ;
102
92
93
+ const getThresholdColor = ( type ) => {
94
+ switch ( type ) {
95
+ case 'good' :
96
+ return '#0bce6b' ;
97
+ case 'improvement' :
98
+ return '#fc5a03' ;
99
+ case 'poor' :
100
+ return '#fc2000' ;
101
+ default :
102
+ return 'var(--text-primary)' ;
103
+ }
104
+ } ;
105
+
103
106
return (
104
107
< div className = 'metric' >
105
108
< ReactHover >
@@ -121,15 +124,15 @@ const radialGraph = (props) => {
121
124
</ p >
122
125
< p > { props . description } </ p >
123
126
< p >
124
- < span style = { { color : '#0bce6b' } } > Good: </ span >
127
+ < span style = { { color : getThresholdColor ( 'good' ) } } > Good: </ span >
125
128
{ `< ${ props . score [ 0 ] } ` }
126
129
</ p >
127
130
< p >
128
- < span style = { { color : '#fc5a03' } } > Needs Improvement: </ span >
131
+ < span style = { { color : getThresholdColor ( 'improvement' ) } } > Needs Improvement: </ span >
129
132
{ `< ${ props . score [ 1 ] } ` }
130
133
</ p >
131
134
< p >
132
- < span style = { { color : '#fc2000' } } > Poor: </ span >
135
+ < span style = { { color : getThresholdColor ( 'poor' ) } } > Poor: </ span >
133
136
{ `> ${ props . score [ 1 ] } ` }
134
137
</ p >
135
138
</ div >
0 commit comments