Skip to content

Commit 2f46925

Browse files
C-STYRkev-ngoCourageWolfDennisLpzdemircaner
committed
Radial Graphs with correct data implemented in Web Metrics tab
Co-authored-by: kev-ngo <[email protected]> Co-authored-by: CourageWolf <[email protected]> Co-authored-by: DennisLpz <[email protected]> Co-authored-by: demircaner <[email protected]>
1 parent dc9299c commit 2f46925

File tree

3 files changed

+52
-29
lines changed

3 files changed

+52
-29
lines changed

src/app/components/StateRoute.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ const StateRoute = (props: StateRouteProps) => {
119119
};
120120
const renderWebMetrics = () => {
121121
return (
122-
<div>
123-
<WebMetrics webMetrics={webMetrics}/>
124-
<WebMetrics webMetrics={webMetrics}/>
125-
<WebMetrics webMetrics={webMetrics}/>
122+
<div className="web-metrics-container">
123+
<WebMetrics series={(webMetrics.LCP / 2500) * 100} formatted={(val) => ((val / 100) * 2500).toFixed(2)} label="LCP"/>
124+
<WebMetrics series={(webMetrics.FID) * 50} formatted={(val) => ((val / 50)).toFixed(2)} label="FID"/>
125+
<WebMetrics series={(webMetrics.CLS * 50) * 100} formatted={(val) => ((val / 100) / 50).toFixed(2)} label="CLS"/>
126+
<WebMetrics series={(webMetrics.FCP / 1000) * 100} formatted={(val) => ((val / 100) * 1000).toFixed(2)} label="FCP"/>
127+
<WebMetrics series={(webMetrics.TTFB / 10) * 100} formatted={(val) => ((val / 100) * 10).toFixed(2)} label="TTFB"/>
126128
</div>
127129
)
128130
};

src/app/components/WebMetrics.tsx

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
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';
34

4-
const radialGraph = ({webMetrics}) => {
5+
const radialGraph = (props) => {
56
const state = {
67

7-
series: [(webMetrics.FCP / 1000) * 100],
8+
series: [props.series],
89
options: {
10+
colors: ['#0bce6b'],
911
chart: {
10-
height: 350,
12+
height: 100,
13+
width: 100,
1114
type: 'radialBar',
1215
toolbar: {
13-
show: true
16+
show: false,
1417
}
1518
},
1619
plotOptions: {
1720
radialBar: {
1821
startAngle: -135,
19-
endAngle: 225,
22+
endAngle: 135,
2023
hollow: {
2124
margin: 0,
22-
size: '90%',
25+
size: '80%',
2326
background: '#242529',
2427
image: undefined,
2528
imageOffsetX: 0,
2629
imageOffsetY: 0,
2730
position: 'front',
2831
dropShadow: {
29-
enabled: true,
32+
enabled: false,
3033
top: 3,
3134
left: 0,
3235
blur: 4,
@@ -35,7 +38,7 @@ const radialGraph = ({webMetrics}) => {
3538
},
3639
track: {
3740
background: '#fff',
38-
strokeWidth: '10%',
41+
strokeWidth: '3%',
3942
margin: 0, // margin is in pixels
4043
dropShadow: {
4144
enabled: true,
@@ -52,12 +55,10 @@ const radialGraph = ({webMetrics}) => {
5255
offsetY: -10,
5356
show: true,
5457
color: '#fff',
55-
fontSize: '17px'
58+
fontSize: '38px'
5659
},
5760
value: {
58-
formatter: function(val) {
59-
return parseInt(webMetrics.FCP);
60-
},
61+
formatter: props.formatted,
6162
color: '#fff',
6263
fontSize: '25px',
6364
show: true,
@@ -66,38 +67,47 @@ const radialGraph = ({webMetrics}) => {
6667
}
6768
},
6869
fill: {
69-
type: 'gradient',
70+
type: 'solid',
7071
gradient: {
7172
shade: 'dark',
7273
type: 'horizontal',
73-
shadeIntensity: 0.5,
74-
gradientToColors: ['#ABE5A1'],
75-
inverseColors: true,
74+
shadeIntensity: 0.1,
75+
gradientToColors: ['#0bce6b'],
76+
inverseColors: false,
7677
opacityFrom: 1,
7778
opacityTo: 1,
7879
stops: [0, 100]
7980
}
8081
},
8182
stroke: {
82-
lineCap: 'round'
83+
lineCap: 'flat'
8384
},
84-
labels: ['FCP'],
85-
},
86-
87-
85+
labels: [props.label],
86+
},
8887
};
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)
9099

91100
return (
92101

93102

94103
<div id="card">
95104
<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}/>
97106
</div>
98107
</div>
99108

100109
)
101110
}
102111

112+
103113
export default radialGraph;

src/app/styles/layout/_stateContainer.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,14 @@
194194
.router-link-performance.is-active {
195195
font-weight: 600;
196196
}
197+
198+
// Web Metrics Container
199+
.web-metrics-container {
200+
padding: 5rem;
201+
display: flex;
202+
justify-content: center;
203+
align-items: center;
204+
flex-wrap: wrap;
205+
// grid-template-columns: repeat(3, 0.5fr);
206+
// grid-template-rows: repeat(2, 1fr);
207+
}

0 commit comments

Comments
 (0)