Skip to content

Commit fbe897a

Browse files
committed
Update default chart colors and text shadows for better readability with all themes
1 parent 3a04408 commit fbe897a

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## v0.35
44
- Fix tooltips not showing on line charts with one or more hidden series
5+
- Update default chart colors and text shadows for better readability with all themes
56

67
## v0.34 (2025-03-23)
78

sqlpage/apexcharts.js

+26-36
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,29 @@ sqlpage_chart = (() => {
1111
}
1212
}
1313

14-
const tblrColors = Object.fromEntries(
15-
[
16-
"azure",
17-
"red",
18-
"lime",
19-
"purple",
20-
"yellow",
21-
"gray-600",
22-
"orange",
23-
"pink",
24-
"teal",
25-
"indigo",
26-
"cyan",
27-
"green",
28-
"blue-lt",
29-
"yellow-lt",
30-
"pink-lt",
31-
"green-lt",
32-
"orange-lt",
33-
"blue",
34-
"gray-500",
35-
"gray-400",
36-
"gray-300",
37-
"gray-200",
38-
"gray-100",
39-
"gray-50",
40-
"black",
41-
].map((c) => [
42-
c,
43-
getComputedStyle(document.documentElement).getPropertyValue(
44-
`--tblr-${c}`,
45-
),
14+
const tblrColors = [
15+
["blue", "#0054a6", "#6fb0e8"],
16+
["red", "#b71c1c", "#e06666"],
17+
["green", "#2fb344", "#5dc973"],
18+
["pink", "#d6336c", "#e05a8c"],
19+
["purple", "#ae3ec9", "#c264d9"],
20+
["orange", "#7a3214", "#ff8a3d"],
21+
["cyan", "#17a2b8", "#40b9cc"],
22+
["teal", "#0ca678", "#2dc08e"],
23+
["yellow", "#a69600", "#ffb733"],
24+
["indigo", "#4263eb", "#7085f0"],
25+
["azure", "#4299e1", "#6ab0e8"],
26+
["gray", "#555555", "#e0e0e0"],
27+
["black", "#000000", "#000000"],
28+
["white", "#ffffff", "#ffffff"],
29+
];
30+
const colorNames = Object.fromEntries(
31+
tblrColors.flatMap(([name, dark, light]) => [
32+
[name, dark],
33+
[`${name}-lt`, light],
4634
]),
4735
);
36+
const isDarkTheme = document.body?.dataset?.bsTheme === "dark";
4837

4938
/** @typedef { { [name:string]: {data:{x:number|string|Date,y:number}[], name:string} } } Series */
5039

@@ -114,8 +103,9 @@ sqlpage_chart = (() => {
114103
if (data.ymax == null) data.ymax = undefined;
115104

116105
const colors = [
117-
...data.colors.filter((c) => c).map((c) => tblrColors[c]),
118-
...Object.values(tblrColors),
106+
...data.colors.filter((c) => c).map((c) => colorNames[c]),
107+
...tblrColors.map(([_, dark, light]) => (isDarkTheme ? dark : light)),
108+
...tblrColors.map(([_, dark, light]) => (isDarkTheme ? light : dark)),
119109
];
120110

121111
let series = Object.values(series_map);
@@ -152,8 +142,8 @@ sqlpage_chart = (() => {
152142
dataLabels: {
153143
enabled: !!data.labels,
154144
dropShadow: {
155-
enabled: true,
156-
color: "#f6f8fb",
145+
enabled: false,
146+
color: "var(--tblr-primary-bg-subtle)",
157147
},
158148
formatter:
159149
data.type === "rangeBar"

0 commit comments

Comments
 (0)