Skip to content

Commit fa85689

Browse files
Merge pull request #3498 from OneCommunityGlobal/guirong-team-stats-chart
Guirong-Team Stats Bar Chart
2 parents d3192e1 + 01b9536 commit fa85689

4 files changed

Lines changed: 38 additions & 10 deletions

File tree

src/components/TotalOrgSummary/TeamStats/TeamStatsBarChart.jsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {
77
ResponsiveContainer,
88
Cell,
99
LabelList,
10+
Label,
1011
} from 'recharts';
1112
import './TeamStatsBarChart.css';
13+
import { useSelector } from 'react-redux';
1214
import TeamStatsBarLabel from './TeamStatsBarLabel';
1315

1416
function TeamStatsBarChart({ data, yAxisLabel }) {
17+
const darkMode = useSelector(state => state.theme.darkMode);
1518
const totalValue = data.reduce((acc, item) => acc + item.value, 0);
1619
const renderCustomLabel = props => {
1720
const { x, y, width, height, index } = props;
@@ -39,8 +42,24 @@ function TeamStatsBarChart({ data, yAxisLabel }) {
3942
data={data}
4043
margin={{ top: 20, right: 150, left: 20, bottom: 20 }}
4144
>
42-
<XAxis type="number" />
43-
<YAxis type="category" dataKey={yAxisLabel} className="team-stats-y-axis" />
45+
<XAxis type="number" tick={{ fill: darkMode ? 'white' : '#666' }}>
46+
<Label
47+
value="Total Volunteers"
48+
position="insideBottom"
49+
offset={-10}
50+
style={{
51+
fontWeight: 'bold',
52+
fill: darkMode ? 'white' : '#666',
53+
color: darkMode ? 'white' : '#666',
54+
}}
55+
/>
56+
</XAxis>
57+
<YAxis
58+
type="category"
59+
dataKey={yAxisLabel}
60+
className="team-stats-y-axis"
61+
tick={{ fill: darkMode ? 'white' : '#666' }}
62+
/>
4463
<Tooltip />
4564
<Bar dataKey="value" fill="#1B6DDF">
4665
{data.map((_, index) => (

src/components/TotalOrgSummary/TeamStats/TeamStatsBarLabel.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
import { useSelector } from 'react-redux';
2+
13
function TeamStatsBarLabel({ x, y, width, height, value, change, percentage }) {
4+
const darkMode = useSelector(state => state.theme.darkMode);
5+
let changeColor;
6+
if (change >= 0) {
7+
changeColor = darkMode ? 'lightgreen' : 'green';
8+
} else {
9+
changeColor = 'red';
10+
}
211
return (
312
<g>
413
<text
514
x={x + width + 30}
615
y={y + height / 2 - 20}
7-
fill="#000"
16+
fill={darkMode ? 'white' : '#000'}
817
fontSize="12"
918
textAnchor="start"
1019
dominantBaseline="middle"
@@ -15,7 +24,7 @@ function TeamStatsBarLabel({ x, y, width, height, value, change, percentage }) {
1524
<text
1625
x={x + width + 20}
1726
y={y + height / 2}
18-
fill="#666"
27+
fill={darkMode ? 'white' : '#666'}
1928
fontSize="12"
2029
textAnchor="start"
2130
dominantBaseline="middle"
@@ -26,7 +35,7 @@ function TeamStatsBarLabel({ x, y, width, height, value, change, percentage }) {
2635
<text
2736
x={x + width + 10}
2837
y={y + height / 2 + 20}
29-
fill={change >= 0 ? 'green' : 'red'}
38+
fill={changeColor}
3039
fontSize="12"
3140
textAnchor="start"
3241
dominantBaseline="middle"

src/components/TotalOrgSummary/TotalOrgSummary.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@
5050
margin: 10px;
5151
}
5252

53-
.chart-title.dark-mode p{
53+
.chart-title.dark-mode p {
5454
color: white;
5555
}

src/components/TotalOrgSummary/VolunteerTrendsLineChart/styles.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
position: absolute !important;
77
z-index: 1;
88
transform: translateX(-50%);
9-
box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.2) ;
9+
box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.2);
1010
}
1111

1212
.chart-container {
@@ -23,7 +23,7 @@
2323
}
2424

2525
.custom-date-range > span {
26-
font-weight: bold;
26+
font-weight: bold;
2727
}
2828

2929
.date-filter-container {
@@ -35,12 +35,12 @@
3535

3636
.date-filter-container > select {
3737
margin-top: 0;
38-
width: min-content
38+
width: min-content;
3939
}
4040

4141
@media (max-width: 500px) {
4242
.chart-container {
4343
justify-content: start;
4444
overflow: scroll;
4545
}
46-
}
46+
}

0 commit comments

Comments
 (0)