Skip to content

Commit 9dbcef0

Browse files
committed
size adjustment
1 parent 1fe10c1 commit 9dbcef0

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<div id="background"></div>
1919
<div class="graphs" style="display: none;">
2020
<h2>Technologies</h2>
21-
<svg id="techChart" width="500" height="500" viewBox="0 0 500 500"></svg>
21+
<svg id="techChart" width="400" height="400" viewBox="0 0 400 400"></svg>
2222
<h2>Tech Skills</h2>
23-
<svg id="skillChart" width="500" height="500" viewBox="0 0 500 500"></svg>
23+
<svg id="skillChart" width="400" height="400" viewBox="0 0 400 400"></svg>
2424
</div>
2525
<div class="user"></div>
2626
<div class="wrapper-login">
@@ -42,7 +42,7 @@ <h2>Login Form</h2>
4242
<p id="error-message" style="color: red;"></p>
4343
</div>
4444
<script type="module" src="./js/login.js"></script>
45-
<script type="module" src="./sj/query.js"></script>
45+
<script type="module" src="./js/query.js"></script>
4646
<script type="module" src="./js/skills.js"></script>
4747
<script type="module" src="./js/experience.js"></script>
4848
</body>

js/skills.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@ export async function drawSkills() {
1919
];
2020

2121
function drawSkillChart(svgId, chartData, shapeSides) {
22-
const radius = 200;
23-
const centerX = 250;
24-
const centerY = 250;
22+
const svg = document.getElementById(svgId);
23+
const width = svg.clientWidth;
24+
const height = svg.clientHeight;
25+
const centerX = width / 2;
26+
const centerY = height / 2;
27+
const radius = Math.min(centerX, centerY) * 0.8;
2528
const angleIncrement = 360 / shapeSides;
2629

27-
const svg = document.getElementById(svgId);
30+
// Clear previous contents
31+
while (svg.firstChild) {
32+
svg.removeChild(svg.firstChild);
33+
}
34+
35+
// Set the viewBox attribute for responsiveness
36+
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
37+
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
2838

2939
// Draw the 100% radius circle
3040
const outerCircle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
@@ -89,6 +99,14 @@ export async function drawSkills() {
8999
});
90100
}
91101

92-
drawSkillChart('techChart', techData, techData.length);
93-
drawSkillChart('skillChart', techSkills, techSkills.length);
102+
function resizeCharts() {
103+
drawSkillChart('techChart', techData, techData.length);
104+
drawSkillChart('skillChart', techSkills, techSkills.length);
105+
}
106+
107+
// Initial draw
108+
resizeCharts();
109+
110+
// Redraw charts on window resize
111+
window.addEventListener('resize', resizeCharts);
94112
}

0 commit comments

Comments
 (0)