fix: theme-aware chart colors — readable axes and tooltips in light mode

This commit is contained in:
Davide Scaini
2026-04-15 22:18:06 +02:00
parent a95dd07e22
commit 5205a41224
2 changed files with 40 additions and 12 deletions
+8 -2
View File
@@ -82,6 +82,10 @@
$: colorMap = Object.fromEntries(selectedKeys.map((k, i) => [k, curveColor(k, i)]));
function getAxisColor() {
return document.documentElement.getAttribute('data-theme') === 'light' ? '#52525b' : '#a1a1aa';
}
function renderChart(data: typeof plotData, cmap: typeof colorMap) {
if (!chartEl) return;
chartEl.innerHTML = '';
@@ -95,7 +99,7 @@
height: 320,
marginLeft: 52,
marginBottom: 40,
style: { background: 'transparent', color: '#e4e4e7' },
style: { background: 'transparent', color: getAxisColor() },
x: {
type: 'log',
label: 'Duration',
@@ -160,7 +164,9 @@
onMount(() => {
const ro = new ResizeObserver(() => renderChart(currentPlotData, currentColorMap));
ro.observe(chartEl);
return () => ro.disconnect();
const mo = new MutationObserver(() => renderChart(currentPlotData, currentColorMap));
mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
return () => { ro.disconnect(); mo.disconnect(); };
});
// ── Toggle helpers ─────────────────────────────────────────────────────────