Fix Bug
This commit is contained in:
@@ -20,7 +20,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
const { theme, systemTheme } = useTheme();
|
||||
const { theme } = useTheme();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -44,7 +44,7 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
reset: true
|
||||
}
|
||||
},
|
||||
background: theme === 'dark' || systemTheme === 'dark' ? '#0F172B' : '#fff',
|
||||
background: theme === 'dark' ? '#0F172B' : '#fff',
|
||||
zoom: {
|
||||
enabled: true,
|
||||
type: 'x',
|
||||
@@ -59,7 +59,7 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
markers: {
|
||||
size: 5,
|
||||
strokeWidth: 2,
|
||||
strokeColors: theme === 'dark' || systemTheme === 'dark' ? ['#fff'] : ['#3B82F6'],
|
||||
strokeColors: theme === 'dark' ? ['#fff'] : ['#3B82F6'],
|
||||
colors: ['#3B82F6'],
|
||||
hover: {
|
||||
size: 7
|
||||
@@ -86,22 +86,22 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
style: {
|
||||
fontSize: '14px',
|
||||
fontWeight: 'bold',
|
||||
color: theme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
color: theme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
labels: {
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
colors: theme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
colors: theme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
axisBorder: {
|
||||
show: true,
|
||||
color: theme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
color: theme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
},
|
||||
axisTicks: {
|
||||
show: true,
|
||||
color: theme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
color: theme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
}
|
||||
},
|
||||
yaxis: {
|
||||
@@ -110,13 +110,13 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
style: {
|
||||
fontSize: '14px',
|
||||
fontWeight: 'bold',
|
||||
color: theme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
color: theme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
labels: {
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
colors: theme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
colors: theme === 'dark' ? '#fff' : '#000'
|
||||
},
|
||||
formatter: function (val: number) {
|
||||
return val.toFixed(2);
|
||||
@@ -126,11 +126,11 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
max: 4,
|
||||
axisBorder: {
|
||||
show: true,
|
||||
color: theme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
color: theme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
borderColor: theme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB',
|
||||
borderColor: theme === 'dark' ? '#374151' : '#E5E7EB',
|
||||
strokeDashArray: 4,
|
||||
padding: {
|
||||
top: 20,
|
||||
@@ -141,7 +141,7 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
},
|
||||
colors: ['#3B82F6'],
|
||||
tooltip: {
|
||||
theme: theme === 'dark' || systemTheme === 'dark' ? 'dark' : 'light',
|
||||
theme: theme === 'dark' ? 'dark' : 'light',
|
||||
y: {
|
||||
formatter: function (val: number) {
|
||||
return val.toFixed(2);
|
||||
@@ -156,30 +156,30 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
position: 'top',
|
||||
horizontalAlign: 'right',
|
||||
labels: {
|
||||
colors: theme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
colors: theme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Update theme when it changes
|
||||
useEffect(() => {
|
||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||
const currentTheme = theme;
|
||||
setOptions(prev => ({
|
||||
...prev,
|
||||
chart: {
|
||||
...prev.chart,
|
||||
background: currentTheme === 'dark' || systemTheme === 'dark' ? '#0F172B' : '#fff',
|
||||
background: currentTheme === 'dark' ? '#0F172B' : '#fff',
|
||||
},
|
||||
dataLabels: {
|
||||
...prev.dataLabels,
|
||||
style: {
|
||||
...prev.dataLabels?.style,
|
||||
colors: [currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000']
|
||||
colors: [currentTheme === 'dark' ? '#fff' : '#000']
|
||||
},
|
||||
background: {
|
||||
...prev.dataLabels?.background,
|
||||
foreColor: currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000',
|
||||
borderColor: currentTheme === 'dark' || systemTheme === 'dark' ? '#374151' : '#3B82F6'
|
||||
foreColor: currentTheme === 'dark' ? '#fff' : '#000',
|
||||
borderColor: currentTheme === 'dark' ? '#374151' : '#3B82F6'
|
||||
}
|
||||
},
|
||||
xaxis: {
|
||||
@@ -188,23 +188,23 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
...prev.xaxis?.title,
|
||||
style: {
|
||||
...prev.xaxis?.title?.style,
|
||||
color: currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
color: currentTheme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
labels: {
|
||||
...prev.xaxis?.labels,
|
||||
style: {
|
||||
...prev.xaxis?.labels?.style,
|
||||
colors: currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
colors: currentTheme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
axisBorder: {
|
||||
...prev.xaxis?.axisBorder,
|
||||
color: currentTheme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
color: currentTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
},
|
||||
axisTicks: {
|
||||
...prev.xaxis?.axisTicks,
|
||||
color: currentTheme === 'dark' || systemTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
color: currentTheme === 'dark' ? '#374151' : '#E5E7EB'
|
||||
}
|
||||
},
|
||||
yaxis: {
|
||||
@@ -213,23 +213,23 @@ export default function IPKPrestasiChart({ selectedJenisPrestasi }: Props) {
|
||||
...(Array.isArray(prev.yaxis) ? prev.yaxis[0]?.title : prev.yaxis?.title),
|
||||
style: {
|
||||
...(Array.isArray(prev.yaxis) ? prev.yaxis[0]?.title?.style : prev.yaxis?.title?.style),
|
||||
color: currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
color: currentTheme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
},
|
||||
labels: {
|
||||
...(Array.isArray(prev.yaxis) ? prev.yaxis[0]?.labels : prev.yaxis?.labels),
|
||||
style: {
|
||||
...(Array.isArray(prev.yaxis) ? prev.yaxis[0]?.labels?.style : prev.yaxis?.labels?.style),
|
||||
colors: currentTheme === 'dark' || systemTheme === 'dark' ? '#fff' : '#000'
|
||||
colors: currentTheme === 'dark' ? '#fff' : '#000'
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
...prev.tooltip,
|
||||
theme: currentTheme === 'dark' || systemTheme === 'dark' ? 'dark' : 'light'
|
||||
theme: currentTheme === 'dark' ? 'dark' : 'light'
|
||||
}
|
||||
}));
|
||||
}, [theme, systemTheme]);
|
||||
}, [theme]);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
|
||||
Reference in New Issue
Block a user