Skip to content

Commit 3fa6b46

Browse files
Merge pull request #4278 from OneCommunityGlobal/siva/fix-hours-completed-overlap
Siva:Fix overlapping Project box in 'Hours Completed' chart section
2 parents 901b82b + 9c85d20 commit 3fa6b46

2 files changed

Lines changed: 38 additions & 46 deletions

File tree

src/components/TotalOrgSummary/HoursCompleted/HoursCompletedBarChart.jsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,41 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
142142
maxHeight: '548px',
143143
display: 'flex',
144144
flexDirection: 'column',
145+
position: 'relative',
145146
}}
146147
>
148+
{/* Projects box positioned in the right side middle area */}
149+
<div
150+
style={{
151+
position: 'absolute',
152+
top: '40%',
153+
left: '65%',
154+
transform: 'translateY(-50%)',
155+
zIndex: 10,
156+
background: 'white',
157+
borderRadius: 4,
158+
padding: 8,
159+
boxShadow: '0 2px 6px rgba(0,0,0,0.15)',
160+
border: '1px solid #eee',
161+
minWidth: 130,
162+
minHeight: 65,
163+
display: 'grid',
164+
justifyItems: 'center',
165+
gap: 2,
166+
}}
167+
>
168+
<div style={{ color: '#444', fontWeight: 'bold', fontSize: 15 }}>Projects</div>
169+
<div style={{ color: '#222', fontWeight: 'bold', fontSize: 14 }}>
170+
{projectBarInfo.amount}
171+
</div>
172+
<div style={{ color: '#666', fontSize: 10 }}>({projectBarInfo.percentage})</div>
173+
{projectBarInfo.ifcompare && (
174+
<div style={{ color: projectBarInfo.fontcolor, fontSize: 10, fontWeight: 'bold' }}>
175+
{projectBarInfo.change}
176+
</div>
177+
)}
178+
</div>
179+
147180
<div style={{ textAlign: 'center', marginBottom: 0 }}>
148181
<div
149182
style={{
@@ -186,7 +219,6 @@ export default function HoursCompletedBarChart({ isLoading, data, darkMode }) {
186219
tickInterval={tickInterval}
187220
// renderCustomizedLabel={renderCustomizedLabel}
188221
darkMode={darkMode}
189-
projectBarInfo={projectBarInfo}
190222
yAxisLabel="Hours"
191223
/>
192224
</div>

src/components/TotalOrgSummary/TinyBarChart.jsx

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,6 @@ import {
1212
ReferenceLine,
1313
} from 'recharts';
1414

15-
function ProjectLabel({ viewBox, info }) {
16-
return (
17-
<foreignObject
18-
x={viewBox.x + 60}
19-
y={viewBox.y + 10}
20-
width={140}
21-
height={70}
22-
style={{ overflow: 'visible' }}
23-
>
24-
<div
25-
style={{
26-
textAlign: 'left',
27-
color: info.fontcolor,
28-
fontSize: 14,
29-
background: 'white',
30-
borderRadius: 4,
31-
padding: 6,
32-
boxShadow: '0 1px 4px #ccc',
33-
lineHeight: 1.2,
34-
border: '1px solid #eee',
35-
minWidth: 120,
36-
minHeight: 60,
37-
pointerEvents: 'none',
38-
display: 'grid',
39-
justifyItems: 'center',
40-
gap: 1,
41-
}}
42-
>
43-
<div style={{ color: '#444', fontWeight: 'bold', fontSize: 15 }}>Projects</div>
44-
<div style={{ color: '#222', fontWeight: 'bold', fontSize: 14 }}>{info.amount}</div>
45-
<div style={{ color: '#666', fontSize: 10 }}>({info.percentage})</div>
46-
{info.ifcompare && (
47-
<div style={{ color: info.fontcolor, fontSize: 10, fontWeight: 'bold' }}>
48-
{info.change}
49-
</div>
50-
)}
51-
</div>
52-
</foreignObject>
53-
);
54-
}
55-
5615
export default function TinyBarChart(props) {
5716
const {
5817
chartData,
@@ -65,12 +24,13 @@ export default function TinyBarChart(props) {
6524
} = props;
6625

6726
return (
68-
<ResponsiveContainer maxWidth={600} maxHeight={400} minWidth={180} minHeight={340}>
27+
<ResponsiveContainer width="100%" height="100%" maxHeight={400} minWidth={180} minHeight={340}>
6928
<BarChart
7029
data={chartData}
7130
margin={{
7231
top: 50,
7332
bottom: 40,
33+
left: 40,
7434
right: 20,
7535
}}
7636
>
@@ -86,10 +46,11 @@ export default function TinyBarChart(props) {
8646
value: yAxisLabel,
8747
angle: -90,
8848
position: 'insideLeft',
89-
offset: 20,
49+
offset: 5,
9050
fill: darkMode ? 'white' : '#444',
91-
fontSize: 14,
51+
fontSize: 12,
9252
fontWeight: 'bold',
53+
style: { textAnchor: 'middle' },
9354
}}
9455
/>
9556
<Tooltip content={<CustomTooltip />} cursor={{ fill: 'transparent' }} />
@@ -105,7 +66,6 @@ export default function TinyBarChart(props) {
10566
stroke={darkMode ? 'lightgreen' : 'green'}
10667
strokeDasharray="6 6"
10768
ifOverflow="extendDomain"
108-
label={<ProjectLabel info={projectBarInfo} />}
10969
/>
11070
)}
11171
</BarChart>

0 commit comments

Comments
 (0)