1
- import React , { useState } from 'react' ;
2
- import Charts from 'react-apexcharts'
1
+ import React , { useState , useEffect , Component } from 'react' ;
2
+ import Charts from 'react-apexcharts' ;
3
+ import useForceUpdate from './useForceUpdate' ;
3
4
4
- const radialGraph = ( { webMetrics } ) => {
5
+ const radialGraph = ( props ) => {
5
6
const state = {
6
7
7
- series : [ ( webMetrics . FCP / 1000 ) * 100 ] ,
8
+ series : [ props . series ] ,
8
9
options : {
10
+ colors : [ '#0bce6b' ] ,
9
11
chart : {
10
- height : 350 ,
12
+ height : 100 ,
13
+ width : 100 ,
11
14
type : 'radialBar' ,
12
15
toolbar : {
13
- show : true
16
+ show : false ,
14
17
}
15
18
} ,
16
19
plotOptions : {
17
20
radialBar : {
18
21
startAngle : - 135 ,
19
- endAngle : 225 ,
22
+ endAngle : 135 ,
20
23
hollow : {
21
24
margin : 0 ,
22
- size : '90 %' ,
25
+ size : '80 %' ,
23
26
background : '#242529' ,
24
27
image : undefined ,
25
28
imageOffsetX : 0 ,
26
29
imageOffsetY : 0 ,
27
30
position : 'front' ,
28
31
dropShadow : {
29
- enabled : true ,
32
+ enabled : false ,
30
33
top : 3 ,
31
34
left : 0 ,
32
35
blur : 4 ,
@@ -35,7 +38,7 @@ const radialGraph = ({webMetrics}) => {
35
38
} ,
36
39
track : {
37
40
background : '#fff' ,
38
- strokeWidth : '10 %' ,
41
+ strokeWidth : '3 %' ,
39
42
margin : 0 , // margin is in pixels
40
43
dropShadow : {
41
44
enabled : true ,
@@ -52,12 +55,10 @@ const radialGraph = ({webMetrics}) => {
52
55
offsetY : - 10 ,
53
56
show : true ,
54
57
color : '#fff' ,
55
- fontSize : '17px '
58
+ fontSize : '38px '
56
59
} ,
57
60
value : {
58
- formatter : function ( val ) {
59
- return parseInt ( webMetrics . FCP ) ;
60
- } ,
61
+ formatter : props . formatted ,
61
62
color : '#fff' ,
62
63
fontSize : '25px' ,
63
64
show : true ,
@@ -66,38 +67,47 @@ const radialGraph = ({webMetrics}) => {
66
67
}
67
68
} ,
68
69
fill : {
69
- type : 'gradient ' ,
70
+ type : 'solid ' ,
70
71
gradient : {
71
72
shade : 'dark' ,
72
73
type : 'horizontal' ,
73
- shadeIntensity : 0.5 ,
74
- gradientToColors : [ '#ABE5A1 ' ] ,
75
- inverseColors : true ,
74
+ shadeIntensity : 0.1 ,
75
+ gradientToColors : [ '#0bce6b ' ] ,
76
+ inverseColors : false ,
76
77
opacityFrom : 1 ,
77
78
opacityTo : 1 ,
78
79
stops : [ 0 , 100 ]
79
80
}
80
81
} ,
81
82
stroke : {
82
- lineCap : 'round '
83
+ lineCap : 'flat '
83
84
} ,
84
- labels : [ 'FCP' ] ,
85
- } ,
86
-
87
-
85
+ labels : [ props . label ] ,
86
+ } ,
88
87
} ;
89
-
88
+
89
+ let formatted ;
90
+
91
+ const [ webMetricsState , setWebMetricsState ] = useState ( props )
92
+
93
+ useEffect ( ( ) => {
94
+ setWebMetricsState ( props ) ;
95
+ formatted = props . formatted ;
96
+ } , [ props ] )
97
+
98
+ // console.log("props.formatted", props.formatted)
90
99
91
100
return (
92
101
93
102
94
103
< div id = "card" >
95
104
< div id = "chart" >
96
- < Charts options = { state . options } series = { state . series } type = "radialBar" height = { 350 } />
105
+ < Charts options = { state . options } series = { state . series } type = "radialBar" height = { 250 } width = { 250 } />
97
106
</ div >
98
107
</ div >
99
108
100
109
)
101
110
}
102
111
112
+
103
113
export default radialGraph ;
0 commit comments