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' });
};
watch(isDarkTheme, () => {
chartData.value = setChartData();
chartOptions.value = setChartOptions();
});
watch([getPrimary, getSurface], () => {
watch([getPrimary, getSurface, isDarkTheme], () => {
chartData.value = setChartData();
chartOptions.value = setChartOptions();
});

View File

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