Skip to content

Commit f627c85

Browse files
committed
feat: enhance chart rendering with adaptive styling for dark and light themes
1 parent 020fc5a commit f627c85

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/main/resources/templates/report.html

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,26 @@ <h2 style="margin-top:0; font-size: 1.2rem;">AI summary & activity suggestions</
330330
data.addColumn('datetime', columns[0]);
331331
data.addColumn('number', columns[1]);
332332
rows.forEach(r => data.addRow(r));
333+
const isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
333334
const options = {
334335
title: title,
335-
legend: { position: 'none' },
336+
legend: {position: 'none', textStyle: {color: isDark ? '#e6e9f0' : '#172033'}},
337+
backgroundColor: 'transparent',
338+
colors: isDark ? ['#4f8cff'] : undefined,
339+
titleTextStyle: {color: isDark ? '#e6e9f0' : '#172033', fontSize: 14},
336340
height: document.getElementById(elementId)?.offsetHeight || 360,
337341
width: document.getElementById(elementId)?.offsetWidth || undefined,
338-
hAxis: { format: 'M/d HH:mm' },
342+
hAxis: {
343+
format: 'M/d HH:mm',
344+
textStyle: {color: isDark ? '#c9d1e1' : '#51607a'},
345+
gridlines: {color: isDark ? '#23304d' : '#e5eaf2'},
346+
baselineColor: isDark ? '#23304d' : '#e5eaf2'
347+
},
348+
vAxis: {
349+
textStyle: {color: isDark ? '#c9d1e1' : '#51607a'},
350+
gridlines: {color: isDark ? '#23304d' : '#e5eaf2'},
351+
baselineColor: isDark ? '#23304d' : '#e5eaf2'
352+
},
339353
chartArea: { left: 60, top: 40, width: '80%', height: '70%' }
340354
};
341355
const chart = new google.visualization.LineChart(document.getElementById(elementId));
@@ -347,12 +361,26 @@ <h2 style="margin-top:0; font-size: 1.2rem;">AI summary & activity suggestions</
347361
data.addColumn('datetime', columns[0]);
348362
data.addColumn('number', columns[1]);
349363
rows.forEach(r => data.addRow(r));
364+
const isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
350365
const options = {
351366
title: title,
352-
legend: { position: 'none' },
367+
legend: {position: 'none', textStyle: {color: isDark ? '#e6e9f0' : '#172033'}},
368+
backgroundColor: 'transparent',
369+
colors: isDark ? ['#4f8cff'] : undefined,
370+
titleTextStyle: {color: isDark ? '#e6e9f0' : '#172033', fontSize: 14},
353371
height: document.getElementById(elementId)?.offsetHeight || 360,
354372
width: document.getElementById(elementId)?.offsetWidth || undefined,
355-
hAxis: { format: 'M/d HH:mm' },
373+
hAxis: {
374+
format: 'M/d HH:mm',
375+
textStyle: {color: isDark ? '#c9d1e1' : '#51607a'},
376+
gridlines: {color: isDark ? '#23304d' : '#e5eaf2'},
377+
baselineColor: isDark ? '#23304d' : '#e5eaf2'
378+
},
379+
vAxis: {
380+
textStyle: {color: isDark ? '#c9d1e1' : '#51607a'},
381+
gridlines: {color: isDark ? '#23304d' : '#e5eaf2'},
382+
baselineColor: isDark ? '#23304d' : '#e5eaf2'
383+
},
356384
chartArea: { left: 60, top: 40, width: '80%', height: '70%' }
357385
};
358386
const chart = new google.visualization.ColumnChart(document.getElementById(elementId));

0 commit comments

Comments
 (0)