Skip to content

Commit b3c95d7

Browse files
Merge pull request #4971 from OneCommunityGlobal/Sayali_Task21_Fix_Dashboard_Chart_Resize
SAYALI: fix dashboard chart resize and dark mode styling for skills profile page
2 parents e2485dc + 78555a3 commit b3c95d7

5 files changed

Lines changed: 154 additions & 89 deletions

File tree

src/components/HGNSkillsDashboard/SkillsProfilePage/components/RadarChart.jsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { Radar } from 'react-chartjs-2';
2-
import { useSelector } from 'react-redux';
31
import {
42
Chart as ChartJS,
5-
RadialLinearScale,
6-
PointElement,
7-
LineElement,
83
Filler,
9-
Tooltip,
104
Legend,
5+
LineElement,
6+
PointElement,
7+
RadialLinearScale,
8+
Tooltip,
119
} from 'chart.js';
12-
import { useState, useEffect } from 'react';
1310
import PropTypes from 'prop-types';
11+
import { useEffect, useState } from 'react';
12+
import { Radar } from 'react-chartjs-2';
13+
import { useSelector } from 'react-redux';
1414
import styles from '../styles/RadarChart.module.css';
1515

1616
ChartJS.register(RadialLinearScale, PointElement, LineElement, Filler, Tooltip, Legend);
@@ -225,35 +225,28 @@ function RadarChart({ profileData, compact = true }) {
225225
);
226226
}
227227

228-
const { general = {}, frontend = {}, backend = {} } = profileData?.skillInfo || {};
229-
230228
const chartData = {
231229
labels: skillsData.map(skill => (compact ? skill.shortLabel || skill.label : skill.label)),
232230
datasets: [
233231
{
234232
label: 'Skills',
235-
data: SKILL_MAPPINGS.map(skill => skill.value(general, frontend, backend) ?? 0),
236-
backgroundColor: 'rgba(37, 99, 235, 0.16)',
237-
borderColor: '#2563eb',
238-
borderWidth: 2,
239-
pointBackgroundColor: '#1d4ed8',
240-
pointBorderColor: '#eff6ff',
241-
pointHoverBackgroundColor: '#eff6ff',
242-
pointHoverBorderColor: '#1d4ed8',
233+
data: skillsData.map(skill => skill.score),
234+
backgroundColor: compact ? 'rgba(133, 146, 226, 0.35)' : 'rgba(62, 160, 203, 0.2)',
235+
borderColor: compact ? 'rgba(110, 125, 215, 0.9)' : 'rgba(62, 160, 203, 1)',
236+
borderWidth: compact ? 2 : 3,
237+
pointBackgroundColor: compact ? 'rgba(110, 125, 215, 0.95)' : 'rgba(62, 160, 203, 1)',
238+
pointBorderColor: '#fff',
239+
pointHoverBackgroundColor: '#fff',
240+
pointHoverBorderColor: compact ? 'rgba(110,125,215,1)' : 'rgba(62,160,203,1)',
241+
pointRadius: compact ? 4 : 6,
242+
pointHoverRadius: compact ? 6 : 8,
243+
pointBorderWidth: 1.5,
244+
pointHoverBorderWidth: 2,
245+
fill: true,
243246
},
244247
],
245248
};
246249

247-
const customTooltipPlugin = {
248-
id: 'customTooltip',
249-
afterDraw: chart => {
250-
const tooltip = chart.tooltip;
251-
if (tooltip && tooltip.opacity === 0) {
252-
return;
253-
}
254-
},
255-
};
256-
257250
const chartOptions = {
258251
responsive: true,
259252
maintainAspectRatio: true,
@@ -262,10 +255,18 @@ function RadarChart({ profileData, compact = true }) {
262255
r: {
263256
angleLines: {
264257
display: true,
265-
color: compact ? 'rgba(0,0,0,0.08)' : 'rgba(0, 0, 0, 0.1)',
258+
color: darkMode
259+
? 'rgba(255,255,255,0.15)'
260+
: compact
261+
? 'rgba(0,0,0,0.08)'
262+
: 'rgba(0,0,0,0.1)',
266263
},
267264
grid: {
268-
color: compact ? 'rgba(0,0,0,0.08)' : 'rgba(0, 0, 0, 0.1)',
265+
color: darkMode
266+
? 'rgba(255,255,255,0.15)'
267+
: compact
268+
? 'rgba(0,0,0,0.08)'
269+
: 'rgba(0,0,0,0.1)',
269270
},
270271
pointLabels: {
271272
font: {
@@ -279,7 +280,7 @@ function RadarChart({ profileData, compact = true }) {
279280
},
280281
weight: '500',
281282
},
282-
color: compact ? '#555' : '#333',
283+
color: darkMode ? '#ccc' : compact ? '#333' : '#222',
283284
padding: compact ? 10 : 15,
284285
callback: function(value, index) {
285286
// Truncate long labels on small screens
@@ -293,7 +294,11 @@ function RadarChart({ profileData, compact = true }) {
293294
suggestedMax: 10,
294295
ticks: {
295296
stepSize: 2,
296-
display: false,
297+
display: compact ? false : true,
298+
color: '#666',
299+
font: {
300+
size: 10,
301+
},
297302
},
298303
},
299304
},
@@ -332,9 +337,6 @@ function RadarChart({ profileData, compact = true }) {
332337
return tooltipItem.parsed.r > 0;
333338
},
334339
},
335-
datalabels: {
336-
display: false,
337-
},
338340
},
339341
interaction: {
340342
intersect: false,

src/components/HGNSkillsDashboard/SkillsProfilePage/components/RightSection.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { useState } from 'react';
22
import { useSelector } from 'react-redux';
3-
import ProfileDetails from './ProfileDetails';
4-
import Skills from './Skills';
5-
import RadarChart from './RadarChart';
6-
import FrontendSkills from './FrontendSkills';
3+
import styles from '../styles/RightSection.module.css';
4+
import AdditionalInfo from './AdditionalInfo';
75
import BackendSkills from './BackendSkills';
86
import DeploymentSkills from './DeploymentSkills';
7+
import FrontendSkills from './FrontendSkills';
8+
import ProfileDetails from './ProfileDetails';
9+
import RadarChart from './RadarChart';
10+
import Skills from './Skills';
911
import SoftwarePractices from './SoftwarePractices';
10-
import AdditionalInfo from './AdditionalInfo';
11-
import styles from '../styles/RightSection.module.css';
1212

1313
/* function RightSection({ profileData }) { */
1414
function RightSection() {
@@ -25,7 +25,7 @@ function RightSection() {
2525
const renderContent = () => {
2626
switch (selectedSkill) {
2727
case 'Dashboard':
28-
return <RadarChart profileData={profileData} />;
28+
return <RadarChart key={selectedSkill} profileData={profileData} />;
2929
case 'Frontend':
3030
return <FrontendSkills profileData={profileData} />;
3131
case 'Backend':
@@ -35,7 +35,7 @@ function RightSection() {
3535
case 'Software Practices':
3636
return <SoftwarePractices profileData={profileData} />;
3737
default:
38-
return <RadarChart profileData={profileData} />;
38+
return <RadarChart key={selectedSkill} profileData={profileData} />;
3939
}
4040
};
4141

src/components/HGNSkillsDashboard/SkillsProfilePage/styles/LeftSection.module.css

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
.leftSection h1 {
2-
margin: 5px 0;
3-
color: #111827;
4-
}
5-
6-
.leftSection h3 {
7-
margin: 0;
8-
font-size: 20px;
9-
color: #1f2933;
1+
.leftSection {
2+
padding: 8px 8px 24px;
3+
text-align: center;
4+
display: flex;
5+
flex-direction: column;
6+
align-items: center;
7+
justify-content: flex-start;
8+
background: linear-gradient(135deg, #fff 0%, #f1f5f9 100%);
9+
border: 1px solid #e5e7eb;
10+
border-radius: 8px;
1011
}
1112

1213
.profilePic {
@@ -17,7 +18,18 @@
1718
margin-bottom: 15px;
1819
}
1920

20-
@media (max-width: 1100px) {
21+
.leftSection h1 {
22+
margin: 5px 0;
23+
color: #333;
24+
}
25+
26+
.leftSection h3 {
27+
margin: 0;
28+
font-size: 20px;
29+
color: #666;
30+
}
31+
32+
@media (width <= 768px) {
2133
.leftSection {
2234
width: 100%;
2335
padding: 16px 0 12px;
@@ -34,3 +46,8 @@
3446
:global(.dark-mode) .leftSection h3 {
3547
color: #ccc;
3648
}
49+
50+
:global(.dark-mode) .leftSection {
51+
background: linear-gradient(135deg, #2a2f3e 0%, #1e2330 100%);
52+
border-color: #3a4a5a;
53+
}

src/components/HGNSkillsDashboard/SkillsProfilePage/styles/RadarChart.module.css

Lines changed: 79 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@
44
flex-direction: column;
55
justify-content: center;
66
align-items: center;
7-
padding: 10px 0;
8-
margin: 0 auto;
9-
max-width: 720px;
10-
width: 100%;
11-
}
12-
13-
.radarChart canvas {
14-
width: 100% !important;
15-
height: auto !important;
16-
max-width: 720px;
17-
max-height: 640px;
7+
padding: 20px;
8+
background: linear-gradient(145deg, #fff 0%, #f8f9fa 100%);
9+
border-radius: 12px;
10+
box-shadow: 0 4px 20px rgb(0 0 0 / 8%);
11+
border: 1px solid rgb(62 160 203 / 10%);
12+
min-height: 500px;
13+
position: relative;
1814
}
1915

20-
@media (max-width: 1100px) {
21-
.radarChart {
22-
padding: 12px 0;
23-
}
24-
25-
.radarChart canvas {
26-
max-height: 540px;
27-
}
16+
.radarChart.compact {
17+
padding: 0;
18+
background: transparent;
19+
box-shadow: none;
20+
border: none;
21+
min-height: auto;
22+
align-items: stretch;
2823
}
2924

3025
.chartTitle {
@@ -38,7 +33,7 @@
3833
font-size: 24px;
3934
font-weight: 600;
4035
margin-bottom: 8px;
41-
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
36+
text-shadow: 0 1px 2px rgb(0 0 0 / 10%);
4237
}
4338

4439
.chartTitle p {
@@ -61,7 +56,7 @@
6156
.chartContainer canvas {
6257
width: 100% !important;
6358
height: 100% !important;
64-
filter: drop-shadow(0 2px 8px rgba(62, 160, 203, 0.15));
59+
filter: drop-shadow(0 2px 8px rgb(62 160 203 / 15%));
6560
}
6661

6762
.chartLegend {
@@ -84,10 +79,10 @@
8479
.legendColor {
8580
width: 18px;
8681
height: 18px;
87-
background: linear-gradient(135deg, rgba(62, 160, 203, 0.8) 0%, rgba(62, 160, 203, 0.6) 100%);
88-
border: 2px solid rgba(62, 160, 203, 1);
82+
background: linear-gradient(135deg, rgb(62 160 203 / 80%) 0%, rgb(62 160 203 / 60%) 100%);
83+
border: 2px solid rgb(62 160 203 / 100%);
8984
border-radius: 50%;
90-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
85+
box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
9186
}
9287

9388
/* Loading state */
@@ -99,7 +94,7 @@
9994
.loadingSpinner {
10095
width: 40px;
10196
height: 40px;
102-
border: 4px solid rgba(62, 160, 203, 0.2);
97+
border: 4px solid rgb(62 160 203 / 20%);
10398
border-left: 4px solid #3ea0cb;
10499
border-radius: 50%;
105100
animation: spin 1s linear infinite;
@@ -128,22 +123,72 @@
128123
}
129124

130125
/* Responsive breakpoints */
131-
@media (max-width: 768px) {
126+
@media (width <= 768px) {
127+
.radarChart {
128+
padding: 15px;
129+
min-height: 450px;
130+
}
131+
132+
.chartTitle h4 {
133+
font-size: 20px;
134+
}
135+
136+
.chartTitle p {
137+
font-size: 13px;
138+
}
139+
140+
.chartContainer {
141+
max-width: clamp(280px, 58vw, 500px);
142+
}
143+
144+
.legendItem {
145+
font-size: 13px;
146+
}
147+
}
148+
149+
@media (width <= 480px) {
132150
.radarChart {
133-
padding: 10px 0;
151+
padding: 10px;
152+
min-height: 400px;
153+
}
154+
155+
.chartTitle h4 {
156+
font-size: 18px;
157+
}
158+
159+
.chartTitle p {
160+
font-size: 12px;
161+
}
162+
163+
.chartContainer {
164+
max-width: clamp(240px, 78vw, 420px);
165+
}
166+
167+
.chartLegend {
168+
flex-direction: column;
169+
gap: 10px;
170+
margin-top: 15px;
171+
}
172+
173+
.legendItem {
174+
font-size: 12px;
134175
}
135176

136-
.radarChart canvas {
137-
max-height: 460px;
177+
.legendColor {
178+
width: 16px;
179+
height: 16px;
138180
}
139181
}
140182

141-
@media (max-width: 480px) {
142-
.radarChart canvas {
143-
max-height: 380px;
183+
/* High DPI displays */
184+
@media (resolution >= 192dpi) {
185+
.chartContainer canvas {
186+
image-rendering: crisp-edges;
144187
}
145188
}
146189

147-
:global(.dark-mode) .radarChart canvas {
148-
filter: invert(1) hue-rotate(180deg);
190+
:global(.dark-mode) .radarChart {
191+
background: linear-gradient(145deg, #2a2f3e 0%, #1e2330 100%);
192+
border-color: rgb(62 160 203 / 30%);
193+
box-shadow: 0 4px 20px rgb(0 0 0 / 30%);
149194
}

0 commit comments

Comments
 (0)