Chart fixes

This commit is contained in:
tugcekucukoglu
2024-07-30 11:32:11 +03:00
parent fa8ce31973
commit 767dd205b8
2 changed files with 13 additions and 32 deletions

View File

@@ -94,12 +94,7 @@ const formatCurrency = (value) => {
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' }); return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
}; };
watch(isDarkTheme, () => { watch([getPrimary, getSurface, isDarkTheme], () => {
chartData.value = setChartData();
chartOptions.value = setChartOptions();
});
watch([getPrimary, getSurface], () => {
chartData.value = setChartData(); chartData.value = setChartData();
chartOptions.value = setChartOptions(); chartOptions.value = setChartOptions();
}); });

View File

@@ -1,33 +1,29 @@
<script setup> <script setup>
import { useLayout } from '@/layout/composables/layout'; import { useLayout } from '@/layout/composables/layout';
import { ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
const { layoutConfig } = useLayout();
let documentStyle = getComputedStyle(document.documentElement);
let textColor = documentStyle.getPropertyValue('--text-color');
let textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
let surfaceBorder = documentStyle.getPropertyValue('--surface-border');
const { getPrimary, getSurface, isDarkTheme } = useLayout();
const lineData = ref(null); const lineData = ref(null);
const pieData = ref(null); const pieData = ref(null);
const polarData = ref(null); const polarData = ref(null);
const barData = ref(null); const barData = ref(null);
const radarData = ref(null); const radarData = ref(null);
const lineOptions = ref(null); const lineOptions = ref(null);
const pieOptions = ref(null); const pieOptions = ref(null);
const polarOptions = ref(null); const polarOptions = ref(null);
const barOptions = ref(null); const barOptions = ref(null);
const radarOptions = ref(null); const radarOptions = ref(null);
const setColorOptions = () => { onMounted(() => {
documentStyle = getComputedStyle(document.documentElement); setColorOptions();
textColor = documentStyle.getPropertyValue('--text-color'); });
textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
surfaceBorder = documentStyle.getPropertyValue('--surface-border'); const setColorOptions = () => {
}; const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color');
const textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
const surfaceBorder = documentStyle.getPropertyValue('--surface-border');
const setChart = () => {
barData.value = { barData.value = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [ datasets: [
@@ -223,19 +219,9 @@ const setChart = () => {
}; };
watch( watch(
layoutConfig.primary, [getPrimary, getSurface, isDarkTheme],
() => { () => {
setColorOptions(); setColorOptions();
setChart();
},
{ immediate: true }
);
watch(
layoutConfig.darkTheme,
() => {
setColorOptions();
setChart();
}, },
{ immediate: true } { immediate: true }
); );