Skip to content

Commit 6040ea3

Browse files
committed
updated cv
1 parent da9c724 commit 6040ea3

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

assets/script.js

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,40 @@ document.addEventListener("DOMContentLoaded", () => {
4545
totalDisplay.textContent = `‒ CITATIONS: ${total} · H-INDEX: ${hIndex} ‒`;
4646
}
4747

48-
const years = data._yearly_totals;
4948
const chart = document.getElementById('scholar-chart');
5049

51-
if (years && chart) {
52-
// Get the highest citation year to scale the bar heights
53-
const maxCitations = Math.max(...Object.values(years));
54-
55-
for (const [year, count] of Object.entries(years)) {
50+
// 2. Grab the last 4 years (adjust .slice(-4) if you want more/fewer bars)
51+
const allYears = Object.keys(yearsData).sort();
52+
const displayYears = allYears.slice(-4);
53+
54+
if (displayYears.length > 0) {
55+
// 3. Find max citations for the Y-Axis label and bar scaling
56+
const maxCitations = Math.max(...displayYears.map(y => yearsData[y]));
57+
document.getElementById('scholar-y-label').innerText = maxCitations;
58+
59+
// 4. Render the bars and the years under them
60+
displayYears.forEach(year => {
61+
const count = yearsData[year];
62+
63+
// Column container
64+
const col = document.createElement('div');
65+
col.className = 'scholar-col';
66+
67+
// The visual bar
5668
const bar = document.createElement('div');
5769
bar.className = 'scholar-bar';
58-
bar.style.height = `${(count / maxCitations) * 100}%`;
59-
bar.setAttribute('data-year', year);
60-
bar.setAttribute('data-count', count);
61-
chart.appendChild(bar);
62-
}
70+
bar.style.height = maxCitations > 0 ? `${(count / maxCitations) * 100}%` : '0%';
71+
bar.title = `${year}: ${count} citations`; // Native tooltip on hover
72+
73+
// The text under the bar (truncates '2024' to '24')
74+
const yearLabel = document.createElement('div');
75+
yearLabel.className = 'scholar-year';
76+
yearLabel.innerText = year.slice(-2);
77+
78+
col.appendChild(bar);
79+
col.appendChild(yearLabel);
80+
chart.appendChild(col);
81+
});
6382
}
6483
}
6584

0 commit comments

Comments
 (0)