diff --git a/frontend/src/views/reports/ReportsView.vue b/frontend/src/views/reports/ReportsView.vue index 68cdb06..4c53f78 100644 --- a/frontend/src/views/reports/ReportsView.vue +++ b/frontend/src/views/reports/ReportsView.vue @@ -290,7 +290,6 @@ const snackbarText = ref('') const spendingChartRef = ref() const highlightedCategory = ref(null) -let selectedChartIndex = -1 const spending = ref(null) const incomeExpense = ref(null) @@ -378,6 +377,11 @@ const spendingChartOptions = computed(() => ({ colors: chartColors, labels: spending.value?.categories.map(c => c.categoryName) ?? [], legend: { show: false }, + states: { + active: { filter: { type: 'none' } }, + hover: { filter: { type: 'darken', value: 0.65 } }, + }, + plotOptions: { pie: { expandOnClick: false } }, dataLabels: { style: { colors: ['#FFFFFF'] }, dropShadow: { enabled: true, top: 1, left: 1, blur: 2, opacity: 0.5 } }, tooltip: { y: { @@ -388,27 +392,26 @@ const spendingChartOptions = computed(() => ({ function highlightCategory(categoryName: string) { highlightedCategory.value = categoryName - const chart = spendingChartRef.value?.chart - if (!chart) return + const chartEl = spendingChartRef.value?.$el as HTMLElement | undefined + if (!chartEl) return const labels = spending.value?.categories.map(c => c.categoryName) ?? [] const idx = labels.indexOf(categoryName) if (idx === -1) return - if (selectedChartIndex >= 0 && selectedChartIndex !== idx) { - chart.toggleDataPointSelection(0, selectedChartIndex) - } - if (selectedChartIndex !== idx) { - chart.toggleDataPointSelection(0, idx) - selectedChartIndex = idx - } + // Reset all slices then highlight the target + const paths = chartEl.querySelectorAll('.apexcharts-pie-area') + paths.forEach((p, i) => { + (p as HTMLElement).style.opacity = i === idx ? '1' : '0.35' + }) } function unhighlightCategory() { highlightedCategory.value = null - const chart = spendingChartRef.value?.chart - if (chart && selectedChartIndex >= 0) { - chart.toggleDataPointSelection(0, selectedChartIndex) - selectedChartIndex = -1 - } + const chartEl = spendingChartRef.value?.$el as HTMLElement | undefined + if (!chartEl) return + const paths = chartEl.querySelectorAll('.apexcharts-pie-area') + paths.forEach(p => { + (p as HTMLElement).style.opacity = '1' + }) } const spendingRowProps = ({ item }: any) => ({