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; }