@@ -4,23 +4,21 @@ import ReactHover, { Trigger, Hover } from 'react-hover';
44import { OptionsCursorTrueWithMargin } from '../../../FrontendTypes' ;
55import { setCurrentTabInApp } from '../../../slices/mainSlice' ;
66import { useDispatch } from 'react-redux' ;
7- /*
8- Used to render a single radial graph on the 'Web Metrics' tab
9- */
107
118const radialGraph = ( props ) => {
129 const dispatch = useDispatch ( ) ;
1310 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 ] ,
1512 options : {
16- colors : [ props . color ] , // color of the webmetrics performance bar from 'StateRoute'
13+ colors : [ props . color ] ,
1714 chart : {
1815 height : 100 ,
1916 width : 100 ,
2017 type : 'radialBar' ,
2118 toolbar : {
2219 show : false ,
2320 } ,
21+ foreColor : 'var(--text-primary)' ,
2422 } ,
2523 plotOptions : {
2624 radialBar : {
@@ -48,29 +46,21 @@ const radialGraph = (props) => {
4846 } ,
4947 } ,
5048 track : {
51- background : '#161617 ' ,
52- strokeWidth : '3 %' ,
49+ background : 'var(--border-color-dark) ' ,
50+ strokeWidth : '10 %' ,
5351 margin : 0 ,
54- dropShadow : {
55- enabled : true ,
56- top : - 3 ,
57- left : 0 ,
58- blur : 4 ,
59- opacity : 0.35 ,
60- } ,
6152 } ,
62-
6353 dataLabels : {
6454 show : true ,
6555 name : {
6656 offsetY : - 10 ,
6757 show : true ,
68- color : '#161617 ' ,
58+ color : 'var(--text-primary) ' ,
6959 fontSize : '24px' ,
7060 } ,
7161 value : {
7262 formatter : props . formatted ,
73- color : '#3c6e71 ' ,
63+ color : 'var(--color-primary) ' ,
7464 fontSize : '16px' ,
7565 show : true ,
7666 } ,
@@ -97,9 +87,22 @@ const radialGraph = (props) => {
9787 } ;
9888
9989 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' ) ) ;
10191 } , [ ] ) ;
10292
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+
103106 return (
104107 < div className = 'metric' >
105108 < ReactHover >
@@ -121,15 +124,15 @@ const radialGraph = (props) => {
121124 </ p >
122125 < p > { props . description } </ p >
123126 < p >
124- < span style = { { color : '#0bce6b' } } > Good: </ span >
127+ < span style = { { color : getThresholdColor ( 'good' ) } } > Good: </ span >
125128 { `< ${ props . score [ 0 ] } ` }
126129 </ p >
127130 < p >
128- < span style = { { color : '#fc5a03' } } > Needs Improvement: </ span >
131+ < span style = { { color : getThresholdColor ( 'improvement' ) } } > Needs Improvement: </ span >
129132 { `< ${ props . score [ 1 ] } ` }
130133 </ p >
131134 < p >
132- < span style = { { color : '#fc2000' } } > Poor: </ span >
135+ < span style = { { color : getThresholdColor ( 'poor' ) } } > Poor: </ span >
133136 { `> ${ props . score [ 1 ] } ` }
134137 </ p >
135138 </ div >
0 commit comments