+analytics update
This commit is contained in:
@@ -27,6 +27,7 @@ const dataTableCategories = ref([]);
|
|||||||
const tableColumns = ref([]);
|
const tableColumns = ref([]);
|
||||||
const chartData = ref(null)
|
const chartData = ref(null)
|
||||||
const selectedCategory = ref()
|
const selectedCategory = ref()
|
||||||
|
const formatter = ref(new Intl.NumberFormat('ru-RU', {style: 'currency', currency: 'RUB', minimumFractionDigits: 0}))
|
||||||
|
|
||||||
|
|
||||||
const preparedChartData = computed(() => {
|
const preparedChartData = computed(() => {
|
||||||
@@ -67,9 +68,9 @@ const chartOptions = {
|
|||||||
},
|
},
|
||||||
datalabels: {
|
datalabels: {
|
||||||
formatter: function (value) {
|
formatter: function (value) {
|
||||||
return value + " ₽";
|
return formatter.value.format(value);
|
||||||
},
|
},
|
||||||
color: 'blue',
|
|
||||||
align: 'top',
|
align: 'top',
|
||||||
offset: 2,
|
offset: 2,
|
||||||
labels: {
|
labels: {
|
||||||
@@ -132,19 +133,19 @@ const prepareTableData = (categories) => {
|
|||||||
return categories.map((category) => {
|
return categories.map((category) => {
|
||||||
// Начинаем со строки, где есть поле с именем категории
|
// Начинаем со строки, где есть поле с именем категории
|
||||||
const row = {category: category.categoryIcon + " " + category.categoryName};
|
const row = {category: category.categoryIcon + " " + category.categoryName};
|
||||||
const formatter = new Intl.NumberFormat('ru-RU', {style: 'currency', currency: 'RUB', minimumFractionDigits: 0});
|
|
||||||
// Для каждой даты проверяем, есть ли в monthlySums соответствующая запись
|
// Для каждой даты проверяем, есть ли в monthlySums соответствующая запись
|
||||||
allDates.forEach((dateStr) => {
|
allDates.forEach((dateStr) => {
|
||||||
const found = category.monthlySums.find((m) => m.date === dateStr);
|
const found = category.monthlySums.find((m) => m.date === dateStr);
|
||||||
if (found.difference != 0) {
|
if (found.difference != 0) {
|
||||||
if (found.difference > 0) {
|
if (found.difference > 0) {
|
||||||
row[dateStr] = found ? formatter.format(found.total) + "<p class='text-green-600 text-sm'> (+ " + found.difference + "%)</p>" : 0;
|
row[dateStr] = found ? formatter.value.format(found.total) + "<p class='text-green-600 text-sm'> (+ " + found.difference + "%)</p>" : 0;
|
||||||
} else {
|
} else {
|
||||||
row[dateStr] = found ? formatter.format(found.total) + "<p class='text-red-500 text-sm'> (" + found.difference + "%)</p>" : 0;
|
row[dateStr] = found ? formatter.value.format(found.total) + "<p class='text-red-500 text-sm'> (" + found.difference + "%)</p>" : 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
row[dateStr] = found ? formatter.format(found.total) : 0;
|
row[dateStr] = found ? formatter.value.format(found.total) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user