|
791 | 791 | return Math.max(320, Math.floor(width)); |
792 | 792 | } |
793 | 793 |
|
| 794 | + function getChartColors() { |
| 795 | + const isDark = document.documentElement.dataset.theme === 'dark'; |
| 796 | + return { |
| 797 | + textColor: isDark ? '#e2e8f0' : '#0f172a', |
| 798 | + cardBg: isDark ? '#111827' : '#ffffff', |
| 799 | + borderColor: isDark ? '#1f2937' : '#cdd5e7' |
| 800 | + }; |
| 801 | + } |
| 802 | + |
794 | 803 | function buildLineSpec(intervals, width, height, enabledSeries) { |
| 804 | + const chartColors = getChartColors(); |
795 | 805 | const points = intervals.flatMap(row => ( |
796 | 806 | enabledSeries.map(series => ({ |
797 | 807 | interval_ts: row.interval_ts, |
|
826 | 836 | { name: "color", type: "ordinal", domain: enabledSeries.map(series => series.key), range: enabledSeries.map(series => series.color || "#666") } |
827 | 837 | ], |
828 | 838 | axes: [ |
829 | | - { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true }, |
830 | | - { orient: "left", scale: "y" } |
| 839 | + { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true, labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor }, |
| 840 | + { orient: "left", scale: "y", labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor } |
831 | 841 | ], |
832 | 842 | signals: [ |
833 | 843 | { name: "hoverTs", value: null, on: [ |
|
934 | 944 | } |
935 | 945 |
|
936 | 946 | function buildStackedBarSpec(intervals, width, height, enabledSeries) { |
| 947 | + const chartColors = getChartColors(); |
937 | 948 | const seriesOrder = new Map(enabledSeries.map((series, idx) => [series.key, idx])); |
938 | 949 | const points = intervals.flatMap(row => ( |
939 | 950 | enabledSeries.map(series => ({ |
|
999 | 1010 | { name: "color", type: "ordinal", domain: enabledSeries.map(series => series.key), range: enabledSeries.map(series => series.color || "#666") } |
1000 | 1011 | ], |
1001 | 1012 | axes: [ |
1002 | | - { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true }, |
1003 | | - { orient: "left", scale: "y" } |
| 1013 | + { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true, labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor }, |
| 1014 | + { orient: "left", scale: "y", labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor } |
1004 | 1015 | ], |
1005 | 1016 | marks: [ |
1006 | 1017 | { |
|
1100 | 1111 | } |
1101 | 1112 |
|
1102 | 1113 | function buildOverlayBarSpec(intervals, width, height, enabledSeries) { |
| 1114 | + const chartColors = getChartColors(); |
1103 | 1115 | if (!intervals.length) { |
1104 | 1116 | return { spec: null, points: [] }; |
1105 | 1117 | } |
|
1143 | 1155 | { name: "y", type: "linear", domain: [0, 1], nice: false, range: "height" } |
1144 | 1156 | ], |
1145 | 1157 | axes: [ |
1146 | | - { orient: "bottom", scale: "x", labelOverlap: true }, |
1147 | | - { orient: "left", scale: "y", format: ".0%" } |
| 1158 | + { orient: "bottom", scale: "x", labelOverlap: true, labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor }, |
| 1159 | + { orient: "left", scale: "y", format: ".0%", labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor } |
1148 | 1160 | ], |
1149 | 1161 | marks: [ |
1150 | 1162 | { |
|
1247 | 1259 | } |
1248 | 1260 |
|
1249 | 1261 | function buildLongevityHeatmapSpec(histogram, width) { |
| 1262 | + const chartColors = getChartColors(); |
1250 | 1263 | const bucketOrder = ["0-1", "2-7", "8-30", "31-90", "91-180", "181-365", "365+"]; |
1251 | 1264 | const points = histogram.map(row => ({ |
1252 | 1265 | interval_ts: Date.parse(`${row.interval_start}T00:00:00Z`), |
|
1266 | 1279 | { name: "color", type: "linear", domain: { data: "heat", field: "count" }, nice: true, range: ["#f2f0f7", "#54278f"] } |
1267 | 1280 | ], |
1268 | 1281 | axes: [ |
1269 | | - { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true }, |
1270 | | - { orient: "left", scale: "y" } |
| 1282 | + { orient: "bottom", scale: "x", format: "%Y-%m-%d", formatType: "utc", labelOverlap: true, labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor }, |
| 1283 | + { orient: "left", scale: "y", labelColor: chartColors.textColor, tickColor: chartColors.textColor, domainColor: chartColors.textColor } |
1271 | 1284 | ], |
1272 | 1285 | marks: [ |
1273 | 1286 | { |
|
0 commit comments