diff --git a/src/core/explorer.ts b/src/core/explorer.ts index 39267895..30849d5b 100644 --- a/src/core/explorer.ts +++ b/src/core/explorer.ts @@ -268,7 +268,8 @@ export enum TransactionExplorerValueMetricType { SourceAmountRange = 'sourceAmountRange', SourceAmountInterquartileRange = 'sourceAmountInterquartileRange', SourceAmountVariance = 'sourceAmountVariance', - SourceAmountStandardDeviation = 'sourceAmountStandardDeviation' + SourceAmountStandardDeviation = 'sourceAmountStandardDeviation', + SourceAmountCoefficientOfVariation = 'sourceAmountCoefficientOfVariation' } export class TransactionExplorerValueMetric implements NameValue { @@ -286,6 +287,7 @@ export class TransactionExplorerValueMetric implements NameValue { public static readonly SourceAmountInterquartileRange = new TransactionExplorerValueMetric('Interquartile Range (Q3 - Q1)', TransactionExplorerValueMetricType.SourceAmountInterquartileRange, true, true); public static readonly SourceAmountVariance = new TransactionExplorerValueMetric('Variance', TransactionExplorerValueMetricType.SourceAmountVariance, false, false); public static readonly SourceAmountStandardDeviation = new TransactionExplorerValueMetric('Standard Deviation', TransactionExplorerValueMetricType.SourceAmountStandardDeviation, false, false); + public static readonly SourceAmountCoefficientOfVariation = new TransactionExplorerValueMetric('Coefficient of Variation', TransactionExplorerValueMetricType.SourceAmountCoefficientOfVariation, false, false); public static readonly Default = TransactionExplorerValueMetric.SourceAmountSum; diff --git a/src/locales/de.json b/src/locales/de.json index 4349edfb..ff52dd9a 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Kontoliste", "This Week": "Diese Woche", "This Month": "Dieser Monat", diff --git a/src/locales/en.json b/src/locales/en.json index fa3c33c1..1627bcfd 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Account List", "This Week": "This Week", "This Month": "This Month", diff --git a/src/locales/es.json b/src/locales/es.json index 5d5d7a0c..6d7ae818 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Lista de Cuentas", "This Week": "Esta Semana", "This Month": "Este Mes", diff --git a/src/locales/fr.json b/src/locales/fr.json index 3aedaa3f..8a600fe4 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Liste des comptes", "This Week": "Cette semaine", "This Month": "Ce mois", diff --git a/src/locales/it.json b/src/locales/it.json index a9c916f9..d3302a5a 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Elenco account", "This Week": "Questa settimana", "This Month": "Questo mese", diff --git a/src/locales/ja.json b/src/locales/ja.json index 6e1dd303..f3d883f7 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "口座リスト", "This Week": "今週", "This Month": "今月", diff --git a/src/locales/kn.json b/src/locales/kn.json index 591b3dfe..a74b3a8b 100644 --- a/src/locales/kn.json +++ b/src/locales/kn.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "ಖಾತೆಗಳ ಪಟ್ಟಿ", "This Week": "ಈ ವಾರ", "This Month": "ಈ ತಿಂಗಳು", diff --git a/src/locales/ko.json b/src/locales/ko.json index effab2f3..b564c108 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "계좌 목록", "This Week": "이번 주", "This Month": "이번 달", diff --git a/src/locales/nl.json b/src/locales/nl.json index 085db518..7c339657 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Rekeningenlijst", "This Week": "Deze week", "This Month": "Deze maand", diff --git a/src/locales/pt_BR.json b/src/locales/pt_BR.json index 80163650..aaef2420 100644 --- a/src/locales/pt_BR.json +++ b/src/locales/pt_BR.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Lista de Contas", "This Week": "Esta Semana", "This Month": "Este Mês", diff --git a/src/locales/ru.json b/src/locales/ru.json index d735977c..3a30ccbe 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Список счетов", "This Week": "На этой неделе", "This Month": "В этом месяце", diff --git a/src/locales/sl.json b/src/locales/sl.json index 6da7d2b3..040fabc9 100644 --- a/src/locales/sl.json +++ b/src/locales/sl.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Seznam računov", "This Week": "Ta teden", "This Month": "Ta mesec", diff --git a/src/locales/ta.json b/src/locales/ta.json index d682e814..c848b29c 100644 --- a/src/locales/ta.json +++ b/src/locales/ta.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "கணக்குகளின் பட்டியல்", "This Week": "இந்த வாரம்", "This Month": "இந்த மாதம்", diff --git a/src/locales/th.json b/src/locales/th.json index d5d22195..df8cf18d 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "รายการบัญชี", "This Week": "สัปดาห์นี้", "This Month": "เดือนนี้", diff --git a/src/locales/tr.json b/src/locales/tr.json index ec63b735..d9014ba8 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Hesap Listesi", "This Week": "Bu Hafta", "This Month": "Bu Ay", diff --git a/src/locales/uk.json b/src/locales/uk.json index a13e81dc..a3af4ca3 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Список рахунків", "This Week": "Цього тижня", "This Month": "Цього місяця", diff --git a/src/locales/vi.json b/src/locales/vi.json index 4326ebd2..60681236 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "Interquartile Range (Q3 - Q1)", "Variance": "Variance", "Standard Deviation": "Standard Deviation", + "Coefficient of Variation": "Coefficient of Variation", "Account List": "Danh sách tài khoản", "This Week": "Tuần này", "This Month": "Tháng này", diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json index d11e9f31..61a0dc6e 100644 --- a/src/locales/zh_Hans.json +++ b/src/locales/zh_Hans.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "四分位距 (Q3 - Q1)", "Variance": "方差", "Standard Deviation": "标准差", + "Coefficient of Variation": "变异系数", "Account List": "账户列表", "This Week": "本周", "This Month": "本月", diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json index 97411c45..57cf32e6 100644 --- a/src/locales/zh_Hant.json +++ b/src/locales/zh_Hant.json @@ -1792,6 +1792,7 @@ "Interquartile Range (Q3 - Q1)": "四分位距 (Q3 - Q1)", "Variance": "變異數", "Standard Deviation": "標準差", + "Coefficient of Variation": "變異係數", "Account List": "帳戶清單", "This Week": "本週", "This Month": "本月", diff --git a/src/stores/explorer.ts b/src/stores/explorer.ts index a3db649b..8d657f97 100644 --- a/src/stores/explorer.ts +++ b/src/stores/explorer.ts @@ -128,6 +128,7 @@ export interface InsightsExplorerTransactionStatisticData { interquartileRange: number; variance?: number; standardDeviation?: number; + coefficientOfVariation?: number; } export const useExplorersStore = defineStore('explorers', () => { @@ -623,7 +624,8 @@ export const useExplorersStore = defineStore('explorers', () => { range: 0, interquartileRange: 0, variance: undefined, - standardDeviation: undefined + standardDeviation: undefined, + coefficientOfVariation: undefined }; const sourceAmounts: number[] = []; @@ -701,6 +703,7 @@ export const useExplorersStore = defineStore('explorers', () => { const sumOfSquaredDifferences: number = sourceAmounts.reduce((sum, amount) => sum + Math.pow(amount / 100.0 - averageAmountForVarianceCalculation, 2), 0); statisticData.variance = sumOfSquaredDifferences / sourceAmounts.length; statisticData.standardDeviation = Math.sqrt(statisticData.variance); + statisticData.coefficientOfVariation = averageAmountForVarianceCalculation !== 0 ? statisticData.standardDeviation / averageAmountForVarianceCalculation : undefined; } return statisticData; @@ -851,14 +854,21 @@ export const useExplorersStore = defineStore('explorers', () => { } else { value = 0; } - } else if (valueMetric === TransactionExplorerValueMetric.SourceAmountVariance) { - const averageSourceAmountInDefaultCurrency = allSourceAmountsInDefaultCurrency.length > 0 ? totalSourceAmountSumInDefaultCurrency / allSourceAmountsInDefaultCurrency.length / 100.0 : 0; - const sumOfSquaredDifferences = allSourceAmountsInDefaultCurrency.reduce((sum, amount) => sum + Math.pow(amount / 100.0 - averageSourceAmountInDefaultCurrency, 2), 0); - value = allSourceAmountsInDefaultCurrency.length > 0 ? sumOfSquaredDifferences / allSourceAmountsInDefaultCurrency.length : 0; - } else if (valueMetric === TransactionExplorerValueMetric.SourceAmountStandardDeviation) { - const averageSourceAmountInDefaultCurrency = allSourceAmountsInDefaultCurrency.length > 0 ? totalSourceAmountSumInDefaultCurrency / allSourceAmountsInDefaultCurrency.length / 100.0 : 0; - const sumOfSquaredDifferences = allSourceAmountsInDefaultCurrency.reduce((sum, amount) => sum + Math.pow(amount / 100.0 - averageSourceAmountInDefaultCurrency, 2), 0); - value = allSourceAmountsInDefaultCurrency.length > 0 ? Math.sqrt(sumOfSquaredDifferences / allSourceAmountsInDefaultCurrency.length) : 0; + } else if (valueMetric === TransactionExplorerValueMetric.SourceAmountVariance || valueMetric === TransactionExplorerValueMetric.SourceAmountStandardDeviation || valueMetric === TransactionExplorerValueMetric.SourceAmountCoefficientOfVariation) { + if (allSourceAmountsInDefaultCurrency.length > 0) { + const averageSourceAmountInDefaultCurrency = totalSourceAmountSumInDefaultCurrency / allSourceAmountsInDefaultCurrency.length / 100.0; + const sumOfSquaredDifferences = allSourceAmountsInDefaultCurrency.reduce((sum, amount) => sum + Math.pow(amount / 100.0 - averageSourceAmountInDefaultCurrency, 2), 0); + + if (valueMetric === TransactionExplorerValueMetric.SourceAmountVariance) { + value = sumOfSquaredDifferences / allSourceAmountsInDefaultCurrency.length + } else if (valueMetric === TransactionExplorerValueMetric.SourceAmountStandardDeviation) { + value = Math.sqrt(sumOfSquaredDifferences / allSourceAmountsInDefaultCurrency.length); + } else if (valueMetric === TransactionExplorerValueMetric.SourceAmountCoefficientOfVariation) { + value = averageSourceAmountInDefaultCurrency !== 0 ? Math.sqrt(sumOfSquaredDifferences / allSourceAmountsInDefaultCurrency.length) / averageSourceAmountInDefaultCurrency : 0; + } + } else { + value = 0; + } } dataItems.push({ diff --git a/src/views/desktop/insights/tabs/ExplorerDataTableTab.vue b/src/views/desktop/insights/tabs/ExplorerDataTableTab.vue index a216de60..1db2e476 100644 --- a/src/views/desktop/insights/tabs/ExplorerDataTableTab.vue +++ b/src/views/desktop/insights/tabs/ExplorerDataTableTab.vue @@ -104,6 +104,10 @@