From 75b01cf5f085c62b61c15beaf17475c5259ae34d Mon Sep 17 00:00:00 2001 From: Vladimir Voronin Date: Thu, 23 Jan 2025 14:54:54 +0300 Subject: [PATCH] +analytics update --- src/components/analytics/AnalyticsView.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/analytics/AnalyticsView.vue b/src/components/analytics/AnalyticsView.vue index f6eea4c..a75fe56 100644 --- a/src/components/analytics/AnalyticsView.vue +++ b/src/components/analytics/AnalyticsView.vue @@ -27,6 +27,7 @@ const dataTableCategories = ref([]); const tableColumns = ref([]); const chartData = ref(null) const selectedCategory = ref() +const formatter = ref(new Intl.NumberFormat('ru-RU', {style: 'currency', currency: 'RUB', minimumFractionDigits: 0})) const preparedChartData = computed(() => { @@ -67,9 +68,9 @@ const chartOptions = { }, datalabels: { formatter: function (value) { - return value + " ₽"; + return formatter.value.format(value); }, - color: 'blue', + align: 'top', offset: 2, labels: { @@ -132,19 +133,19 @@ const prepareTableData = (categories) => { return categories.map((category) => { // Начинаем со строки, где есть поле с именем категории const row = {category: category.categoryIcon + " " + category.categoryName}; - const formatter = new Intl.NumberFormat('ru-RU', {style: 'currency', currency: 'RUB', minimumFractionDigits: 0}); + // Для каждой даты проверяем, есть ли в monthlySums соответствующая запись allDates.forEach((dateStr) => { const found = category.monthlySums.find((m) => m.date === dateStr); if (found.difference != 0) { if (found.difference > 0) { - row[dateStr] = found ? formatter.format(found.total) + "

(+ " + found.difference + "%)

" : 0; + row[dateStr] = found ? formatter.value.format(found.total) + "

(+ " + found.difference + "%)

" : 0; } else { - row[dateStr] = found ? formatter.format(found.total) + "

(" + found.difference + "%)

" : 0; + row[dateStr] = found ? formatter.value.format(found.total) + "

(" + found.difference + "%)

" : 0; } } else { - row[dateStr] = found ? formatter.format(found.total) : 0; + row[dateStr] = found ? formatter.value.format(found.total) : 0; }