Commit ·
b2519df
1
Parent(s): 7fad09c
fix: improve score sparkline aesthetics
Browse files- src/js/format.js +10 -2
src/js/format.js
CHANGED
|
@@ -941,7 +941,11 @@ function trackScore(score) {
|
|
| 941 |
}
|
| 942 |
function renderSparkline() {
|
| 943 |
const container = document.getElementById('score-sparkline');
|
| 944 |
-
if (!container
|
|
|
|
|
|
|
|
|
|
|
|
|
| 945 |
const w = 120, h = 30;
|
| 946 |
const max = Math.max(..._scoreHistory, 100);
|
| 947 |
const min = Math.min(..._scoreHistory, 0);
|
|
@@ -951,5 +955,9 @@ function renderSparkline() {
|
|
| 951 |
const y = h - ((v - min) / range) * h;
|
| 952 |
return `${x},${y}`;
|
| 953 |
}).join(' ');
|
| 954 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 955 |
}
|
|
|
|
| 941 |
}
|
| 942 |
function renderSparkline() {
|
| 943 |
const container = document.getElementById('score-sparkline');
|
| 944 |
+
if (!container) return;
|
| 945 |
+
if (_scoreHistory.length < 3) {
|
| 946 |
+
container.innerHTML = '';
|
| 947 |
+
return;
|
| 948 |
+
}
|
| 949 |
const w = 120, h = 30;
|
| 950 |
const max = Math.max(..._scoreHistory, 100);
|
| 951 |
const min = Math.min(..._scoreHistory, 0);
|
|
|
|
| 955 |
const y = h - ((v - min) / range) * h;
|
| 956 |
return `${x},${y}`;
|
| 957 |
}).join(' ');
|
| 958 |
+
const polygonPoints = `0,${h} ${points} ${w},${h}`;
|
| 959 |
+
container.innerHTML = `<svg width="${w}" height="${h}" class="sparkline">
|
| 960 |
+
<polygon points="${polygonPoints}" fill="var(--color-primary)" opacity="0.15"/>
|
| 961 |
+
<polyline points="${points}" fill="none" stroke="var(--color-primary)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
| 962 |
+
</svg>`;
|
| 963 |
}
|