diff --git a/src/components/ToolBar.vue b/src/components/ToolBar.vue index e3f6adc..91d6034 100644 --- a/src/components/ToolBar.vue +++ b/src/components/ToolBar.vue @@ -5,6 +5,12 @@
Аналитика
+(+ " + found.difference + "%)
" : 0; + row[dateStr] = found ? formatter.value.format(found.total) + "(+ " + found.difference + "%)
" : 0; } else { - row[dateStr] = found ? formatter.value.format(found.total) + "(" + found.difference + "%)
" : 0; + row[dateStr] = found ? formatter.value.format(found.total) + "(" + found.difference + "%)
" : 0; } } else { - row[dateStr] = found ? formatter.value.format(found.total) : 0; } - - + if (!sums[dateStr]) { + sums[dateStr] = 0 + } + sums[dateStr] += found.total }); return row; }); + + + let previousSum = 0; + Object.keys(sums).forEach(key => { + + console.log(previousSum) + let difference = previousSum != 0 ? ((sums[key] - previousSum) / previousSum) * 100 : 0 + if (sums[key] != previousSum) { + previousSum = sums[key]; + } + let color = "" + if (difference > 0) { + color = "text-red-500" + } else color = "text-green-600" + sums[key] = formatter.value.format(sums[key]) + `(` + difference.toFixed(0) + "%)
"; + + }); + + + rows.push(sums); + return rows; }; @@ -223,7 +245,7 @@ onMounted(async () => { -