Enlarged pie chart
This commit is contained in:
1 parent
06e1c35e77
commit
146a646365
2 files changed
+20
-12
No files matched your search
@@ -20,12 +20,18 @@ const PieCenterLabel = ({ value, color, setExpand }) => {
|
|||||||
transform={`translate(${width / 2}, ${height / 2})`}
|
transform={`translate(${width / 2}, ${height / 2})`}
|
||||||
onMouseEnter={() => setExpand(true)}
|
onMouseEnter={() => setExpand(true)}
|
||||||
>
|
>
|
||||||
<circle cx={0} cy={0} r={width / 3} fill="transparent" />
|
<circle
|
||||||
|
cx={0}
|
||||||
|
cy={0}
|
||||||
|
r={width / 3}
|
||||||
|
fill="transparent"
|
||||||
|
pointerEvents="none"
|
||||||
|
/>
|
||||||
<text
|
<text
|
||||||
className="pie-label"
|
className="pie-label"
|
||||||
style={{
|
style={{
|
||||||
fill: color,
|
fill: color,
|
||||||
fontSize: "45px",
|
fontSize: 48,
|
||||||
textAnchor: "middle",
|
textAnchor: "middle",
|
||||||
dominantBaseline: "central",
|
dominantBaseline: "central",
|
||||||
userSelect: "none",
|
userSelect: "none",
|
||||||
@@ -60,7 +66,7 @@ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
|
|||||||
|
|
||||||
// Compute the midpoint angle in radians
|
// Compute the midpoint angle in radians
|
||||||
const angle = (((startAngle + endAngle) / 2) * Math.PI) / 180;
|
const angle = (((startAngle + endAngle) / 2) * Math.PI) / 180;
|
||||||
const radius = height / 3.5; // length from center of the circle to where the text is positioned
|
const radius = height / 4; // length from center of the circle to where the text is positioned
|
||||||
|
|
||||||
// Calculate x and y positions
|
// Calculate x and y positions
|
||||||
const x = Math.sin(angle) * radius;
|
const x = Math.sin(angle) * radius;
|
||||||
@@ -74,10 +80,11 @@ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
|
|||||||
y={y}
|
y={y}
|
||||||
style={{
|
style={{
|
||||||
fill: highlighted ? color : "rgba(0,0,0,0)",
|
fill: highlighted ? color : "rgba(0,0,0,0)",
|
||||||
fontSize: "12px",
|
fontSize: 12,
|
||||||
textAnchor: "middle",
|
textAnchor: "middle",
|
||||||
dominantBaseline: "central",
|
dominantBaseline: "central",
|
||||||
userSelect: "none",
|
userSelect: "none",
|
||||||
|
pointerEvents: "none",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+{value}
|
+{value}
|
||||||
@@ -181,8 +188,8 @@ const PieChart = ({ audits }) => {
|
|||||||
cornerRadius: 2,
|
cornerRadius: 2,
|
||||||
highlightScope: { faded: "global", highlighted: "series" },
|
highlightScope: { faded: "global", highlighted: "series" },
|
||||||
faded: {
|
faded: {
|
||||||
innerRadius: 63,
|
innerRadius: 73,
|
||||||
outerRadius: 70,
|
outerRadius: 80,
|
||||||
additionalRadius: -20,
|
additionalRadius: -20,
|
||||||
arcLabelRadius: 5,
|
arcLabelRadius: 5,
|
||||||
},
|
},
|
||||||
@@ -197,7 +204,7 @@ const PieChart = ({ audits }) => {
|
|||||||
return props;
|
return props;
|
||||||
};
|
};
|
||||||
|
|
||||||
const pieSize = { width: 210, height: 200 };
|
const pieSize = { width: 230, height: 230 };
|
||||||
const pieData = getPieData(audits);
|
const pieData = getPieData(audits);
|
||||||
const colorMap = getColors(performance);
|
const colorMap = getColors(performance);
|
||||||
|
|
||||||
@@ -215,7 +222,7 @@ const PieChart = ({ audits }) => {
|
|||||||
color: colorMap.bg,
|
color: colorMap.bg,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
outerRadius: 67,
|
outerRadius: 77,
|
||||||
cx: pieSize.width / 2,
|
cx: pieSize.width / 2,
|
||||||
},
|
},
|
||||||
...pieData,
|
...pieData,
|
||||||
@@ -260,7 +267,7 @@ const PieChart = ({ audits }) => {
|
|||||||
color: colorMap.bg,
|
color: colorMap.bg,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
outerRadius: 67,
|
outerRadius: 77,
|
||||||
cx: pieSize.width / 2,
|
cx: pieSize.width / 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -270,8 +277,8 @@ const PieChart = ({ audits }) => {
|
|||||||
color: colorMap.stroke,
|
color: colorMap.stroke,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
innerRadius: 63,
|
innerRadius: 73,
|
||||||
outerRadius: 70,
|
outerRadius: 80,
|
||||||
paddingAngle: 5,
|
paddingAngle: 5,
|
||||||
cornerRadius: 2,
|
cornerRadius: 2,
|
||||||
startAngle: 0,
|
startAngle: 0,
|
||||||
|
|||||||
@@ -305,7 +305,8 @@ const PageSpeedDetails = () => {
|
|||||||
textAlign="center"
|
textAlign="center"
|
||||||
minWidth="300px"
|
minWidth="300px"
|
||||||
flex={1}
|
flex={1}
|
||||||
p={theme.spacing(12)}
|
pt={theme.spacing(6)}
|
||||||
|
pb={theme.spacing(12)}
|
||||||
>
|
>
|
||||||
<PieChart audits={audits} />
|
<PieChart audits={audits} />
|
||||||
<Typography fontSize={13} mt="auto">
|
<Typography fontSize={13} mt="auto">
|
||||||
|
|||||||
Reference in new issue
Block a user