mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: chart not rendering when theme auto
This commit is contained in:
1 parent
c2be3c44cb
commit
877b6dd979
1 file changed
+17
-2
@@ -16,6 +16,7 @@
|
||||
import { app } from '$lib/stores/app';
|
||||
import light from './echartLight.json';
|
||||
import dark from './echartDark.json';
|
||||
import { browser } from '$app/env';
|
||||
|
||||
echarts.use([
|
||||
TitleComponent,
|
||||
@@ -59,11 +60,25 @@
|
||||
let timeoutId: unknown;
|
||||
|
||||
$: option && setOption();
|
||||
$: if (myChart && $app.theme) {
|
||||
$: if (myChart && selectedTheme) {
|
||||
makeChart();
|
||||
setOption();
|
||||
}
|
||||
|
||||
$: selectedTheme = $app.theme;
|
||||
$: if ($app.theme === 'auto') {
|
||||
if (browser) {
|
||||
const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (darkThemeMq.matches) {
|
||||
selectedTheme = 'dark';
|
||||
} else {
|
||||
selectedTheme = 'light';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedTheme = $app.theme;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
makeChart();
|
||||
});
|
||||
@@ -85,7 +100,7 @@
|
||||
|
||||
const makeChart = () => {
|
||||
destroyChart();
|
||||
myChart = echarts.init(document.getElementById(`echart-${title}`), $app.theme);
|
||||
myChart = echarts.init(document.getElementById(`echart-${title}`), selectedTheme);
|
||||
series.forEach((s: LineSeriesOption, i: number) => {
|
||||
s.areaStyle = colorToGradient(myChart['_theme'].color[i]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user