diff --git a/generate_html.sh b/generate_html.sh index 7634621..7e0a211 100644 --- a/generate_html.sh +++ b/generate_html.sh @@ -13,7 +13,14 @@ if [ ! -f "$DATA_FILE" ] || [ ! -s "$DATA_FILE" ]; then Speedtest Results @@ -72,13 +79,14 @@ cat > "$HTML_FILE" << EOF @@ -146,17 +154,31 @@ $data_js marker: { size: 6 } }; + // Detect dark mode preference + const isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; + const layout = { - title: 'Internet Speed Over Time', - xaxis: { title: 'Time' }, - yaxis: { title: 'Speed (Mbps)', side: 'left' }, - yaxis2: { title: 'Ping (ms)', overlaying: 'y', side: 'right' }, + title: { + text: 'Internet Speed Over Time', + font: { color: isDark ? '#e0e0e0' : '#333' } + }, + paper_bgcolor: isDark ? '#2a2a2a' : 'white', + plot_bgcolor: isDark ? '#2a2a2a' : 'white', + font: { color: isDark ? '#e0e0e0' : '#333' }, + xaxis: { title: { text: 'Time', font: { color: isDark ? '#e0e0e0' : '#333' } }, gridcolor: isDark ? '#444' : '#e0e0e0', tickfont: { color: isDark ? '#999' : '#666' } }, + yaxis: { title: { text: 'Speed (Mbps)', font: { color: isDark ? '#e0e0e0' : '#333' } }, gridcolor: isDark ? '#444' : '#e0e0e0', tickfont: { color: isDark ? '#999' : '#666' }, side: 'left' }, + yaxis2: { title: { text: 'Ping (ms)', font: { color: isDark ? '#e0e0e0' : '#333' } }, gridcolor: isDark ? '#444' : '#e0e0e0', tickfont: { color: isDark ? '#999' : '#666' }, overlaying: 'y', side: 'right' }, hovermode: 'x unified', showlegend: true, - legend: { x: 0, y: 1.1, orientation: 'h' } + legend: { x: 0, y: 1.1, orientation: 'h', font: { color: isDark ? '#e0e0e0' : '#333' } } }; Plotly.newPlot('chart', [trace1, trace2, trace3], layout, {responsive: true}); + + // Update chart when system theme changes + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { + location.reload(); + });