Skip to content

Commit 39828dc

Browse files
Merge pull request #4141 from OneCommunityGlobal/xinyi_fix_hours_completed_bar_chart
Xinyi - Fix hours completed bar chart
2 parents 630ecbd + 0388eb8 commit 39828dc

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/TotalOrgSummary/HoursCompleted/HoursCompletedBarChart.jsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
8080
color: ['rgba(76,75,245,255)', 'rgba(0,175,244,255)'],
8181
}));
8282
const projectBarInfo = {
83+
ifcompare: projectChangePercentage !== undefined && projectChangePercentage !== null,
8384
amount: projectHours.count,
8485
percentage: `${(projectPercentage * 100).toFixed(2)}%`,
8586
change:
@@ -158,16 +159,22 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
158159
100}% of Total Tangible Hours Submitted to Tasks`}
159160
</span>
160161
{(() => {
161-
const isPositive = data.hoursSubmittedToTasksComparisonPercentage >= 0;
162+
const percentage = data.hoursSubmittedToTasksComparisonPercentage;
163+
164+
if (percentage === undefined || percentage === null) {
165+
// No comparison → hide metrics
166+
return null;
167+
}
168+
const isPositive = percentage >= 0;
162169
let color;
163170
if (isPositive) {
164171
color = darkMode ? 'lightgreen' : 'green';
165172
} else {
166173
color = 'red';
167174
}
168175
const value = isPositive
169-
? `+${(data.hoursSubmittedToTasksComparisonPercentage * 100).toFixed(0)}%`
170-
: `${(data.hoursSubmittedToTasksComparisonPercentage * 100).toFixed(0)}%`;
176+
? `+${(percentage * 100).toFixed(0)}%`
177+
: `${(percentage * 100).toFixed(0)}%`;
171178
return <span style={{ color, marginLeft: 8, fontSize: '12px' }}>{value}</span>;
172179
})()}
173180
</div>
@@ -177,7 +184,7 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
177184
chartData={chartData.filter(item => item.name === 'Tasks')}
178185
maxY={maxY}
179186
tickInterval={tickInterval}
180-
renderCustomizedLabel={renderCustomizedLabel}
187+
// renderCustomizedLabel={renderCustomizedLabel}
181188
darkMode={darkMode}
182189
projectBarInfo={projectBarInfo}
183190
yAxisLabel="Hours"

src/components/TotalOrgSummary/TinyBarChart.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ function ProjectLabel({ viewBox, info }) {
4343
<div style={{ color: '#444', fontWeight: 'bold', fontSize: 15 }}>Projects</div>
4444
<div style={{ color: '#222', fontWeight: 'bold', fontSize: 14 }}>{info.amount}</div>
4545
<div style={{ color: '#666', fontSize: 10 }}>({info.percentage})</div>
46-
<div style={{ color: info.fontcolor, fontSize: 10, fontWeight: 'bold' }}>{info.change}</div>
46+
{info.ifcompare && (
47+
<div style={{ color: info.fontcolor, fontSize: 10, fontWeight: 'bold' }}>
48+
{info.change}
49+
</div>
50+
)}
4751
</div>
4852
</foreignObject>
4953
);

0 commit comments

Comments
 (0)