Skip to content

Commit bb2dda6

Browse files
authored
sync dark mode with chart (#161)
* hidemetadata * hidemetadata
1 parent 0c4020c commit bb2dda6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

frontend/src/pages/leaderboard/components/AiTrendChart.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
formatMicrosecondsNum,
77
formatMicroseconds,
88
} from "../../../lib/utils/ranking";
9+
import { useThemeStore } from "../../../lib/store/themeStore";
910

1011
interface AiTrendChartProps {
1112
leaderboardId: string;
@@ -31,6 +32,9 @@ export default function AiTrendChart({ leaderboardId }: AiTrendChartProps) {
3132
const [data, setData] = useState<AiTrendResponse | null>(null);
3233
const [loading, setLoading] = useState(true);
3334
const [error, setError] = useState<string | null>(null);
35+
const resolvedMode = useThemeStore((state) => state.resolvedMode);
36+
const isDark = resolvedMode === "dark";
37+
const textColor = isDark ? "#e0e0e0" : "#333";
3438

3539
useEffect(() => {
3640
const loadData = async () => {
@@ -153,6 +157,7 @@ export default function AiTrendChart({ leaderboardId }: AiTrendChartProps) {
153157
textStyle: {
154158
fontSize: 16,
155159
fontWeight: "bold",
160+
color: textColor,
156161
},
157162
},
158163
tooltip: {
@@ -172,6 +177,9 @@ export default function AiTrendChart({ leaderboardId }: AiTrendChartProps) {
172177
legend: {
173178
data: Object.keys(h100Data),
174179
bottom: 0,
180+
textStyle: {
181+
color: textColor,
182+
},
175183
},
176184
grid: {
177185
left: "3%",
@@ -185,21 +193,44 @@ export default function AiTrendChart({ leaderboardId }: AiTrendChartProps) {
185193
name: "Submission Time",
186194
nameLocation: "middle",
187195
nameGap: 30,
196+
nameTextStyle: {
197+
color: textColor,
198+
},
188199
axisLabel: {
200+
color: textColor,
189201
formatter: (value: number) => {
190202
const date = new Date(value);
191203
return `${date.getMonth() + 1}/${date.getDate()}`;
192204
},
193205
},
206+
axisLine: {
207+
lineStyle: {
208+
color: textColor,
209+
},
210+
},
194211
},
195212
yAxis: {
196213
type: "value",
197214
name: "Score (lower is better)",
198215
nameLocation: "middle",
199216
nameGap: 70,
217+
nameTextStyle: {
218+
color: textColor,
219+
},
200220
axisLabel: {
221+
color: textColor,
201222
formatter: (value: number) => `${formatMicrosecondsNum(value)}μs`,
202223
},
224+
axisLine: {
225+
lineStyle: {
226+
color: textColor,
227+
},
228+
},
229+
splitLine: {
230+
lineStyle: {
231+
color: isDark ? "#444" : "#ccc",
232+
},
233+
},
203234
},
204235
series,
205236
};

0 commit comments

Comments
 (0)