Compare commits

...

1 Commits

Author SHA1 Message Date
CodeRabbit Fixer
46e4ce16b1 fix: make chart colors reactive to theme changes (#9806)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 16:42:10 +01:00

View File

@@ -13,6 +13,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ChartData } from 'chart.js' import type { ChartData } from 'chart.js'
import { useCssVar } from '@vueuse/core'
import Chart from 'primevue/chart' import Chart from 'primevue/chart'
import { computed } from 'vue' import { computed } from 'vue'
@@ -33,50 +34,58 @@ const chartType = computed(() => props.widget.options?.type ?? 'line')
const chartData = computed(() => value.value || { labels: [], datasets: [] }) const chartData = computed(() => value.value || { labels: [], datasets: [] })
const chartOptions = computed(() => ({ const baseForeground = useCssVar('--color-base-foreground')
responsive: true, const mutedForeground = useCssVar('--color-muted-foreground')
maintainAspectRatio: false,
plugins: { const chartOptions = computed(() => {
legend: { const legendColor = baseForeground.value || '#FFF'
labels: { const axisColor = mutedForeground.value || '#9FA2BD'
color: '#FFF',
usePointStyle: true, return {
pointStyle: 'circle' responsive: true,
} maintainAspectRatio: false,
} plugins: {
}, legend: {
scales: { labels: {
x: { color: legendColor,
ticks: { usePointStyle: true,
color: '#9FA2BD' pointStyle: 'circle'
}, }
grid: {
display: true,
color: '#9FA2BD',
drawTicks: false,
drawOnChartArea: true,
drawBorder: false
},
border: {
display: true,
color: '#9FA2BD'
} }
}, },
y: { scales: {
ticks: { x: {
color: '#9FA2BD' ticks: {
color: axisColor
},
grid: {
display: true,
color: axisColor,
drawTicks: false,
drawOnChartArea: true,
drawBorder: false
},
border: {
display: true,
color: axisColor
}
}, },
grid: { y: {
display: false, ticks: {
drawTicks: false, color: axisColor
drawOnChartArea: false, },
drawBorder: false grid: {
}, display: false,
border: { drawTicks: false,
display: true, drawOnChartArea: false,
color: '#9FA2BD' drawBorder: false
},
border: {
display: true,
color: axisColor
}
} }
} }
} }
})) })
</script> </script>