Skip to content

Commit e403f52

Browse files
committed
Adjust tablet UI for pie chart
1 parent 0a500db commit e403f52

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/components/community-stats/CustomPieChart.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ const COLORS = [
1717
"#000036",
1818
];
1919

20-
const renderCustomizedLabel = ({ name, value, index }) => {
20+
const renderCustomizedLabel = ({ name, value, index, isTablet }) => {
2121
const labelPositions = [
2222
{ x: -290, y: -450 },
2323
{ x: 140, y: 100 },
2424
{ x: 105, y: 130 },
2525
{ x: 106, y: 160 },
26-
{ x: 820, y: 100 },
27-
{ x: 870, y: 130 },
28-
{ x: 850, y: 160 },
29-
{ x: 853, y: 190 },
26+
{ x: isTablet ? 620 : 820, y: 100 },
27+
{ x: isTablet ? 680 : 870, y: 130 },
28+
{ x: isTablet ? 680 : 850, y: 160 },
29+
{ x: isTablet ? 690 : 853, y: 190 },
3030
];
3131

3232
const lineCoordinates = [
3333
{ from: [-270, -450], to: [-290, -500] },
34-
{ from: [370, 100], to: [250, 100] },
35-
{ from: [465, 130], to: [180, 130] },
36-
{ from: [500, 160], to: [190, 160] },
37-
{ from: [530, 100], to: [770, 100] },
38-
{ from: [545, 130], to: [770, 130] },
39-
{ from: [550, 160], to: [770, 160] },
40-
{ from: [545, 190], to: [770, 190] },
34+
{ from: [isTablet ? 300 : 370, 100], to: [250, 100] },
35+
{ from: [isTablet ? 360 : 465, 130], to: [180, 130] },
36+
{ from: [isTablet ? 400 : 500, 160], to: [190, 160] },
37+
{ from: [isTablet ? 430 : 530, 100], to: [isTablet ? 570 : 770, 100] },
38+
{ from: [isTablet ? 445 : 545, 130], to: [isTablet ? 580 : 770, 130] },
39+
{ from: [isTablet ? 450 : 550, 160], to: [isTablet ? 600 : 770, 160] },
40+
{ from: [isTablet ? 446 : 545, 190], to: [isTablet ? 610 : 770, 190] },
4141
];
4242

4343
const strokeColors = [
@@ -136,7 +136,11 @@ export default function CustomPieChart({ data }) {
136136
isAnimationActive={false}
137137
stroke="none"
138138
labelLine={false}
139-
label={!isMobile ? renderCustomizedLabel : false}
139+
label={
140+
!isMobile
141+
? (props) => renderCustomizedLabel({ ...props, isTablet })
142+
: false
143+
}
140144
>
141145
{sortedData.map((_, index) => (
142146
<Cell key={`cell-${index}`} fill={COLORS[index]} />

0 commit comments

Comments
 (0)