Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: new graph cost vs budget on statistics (#793)
Miguel Ribeiro6d673195ba39
diff --git a/includes/i18n/cs.php b/includes/i18n/cs.phpindex aca25c8..9fef294 100644--- a/includes/i18n/cs.php+++ b/includes/i18n/cs.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Rozdělení domácnosti","payment_method_split" => "Rozdělení platebních metod","total_cost_trend" => "Trend celkových nákladů",+ "cost_vs_budget" => "Celkové náklady vs. rozpočet",// About page"about_and_credits" => "O aplikaci a zásluhy","credits" => "Zásluhy",diff --git a/includes/i18n/de.php b/includes/i18n/de.phpindex 934c3ed..74146ed 100644--- a/includes/i18n/de.php+++ b/includes/i18n/de.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Haushalt","payment_method_split" => "Zahlungsmethode","total_cost_trend" => "Kostenentwicklung",+ "cost_vs_budget" => "Kosten vs. Budget",// About page"about_and_credits" => "Informationen und Danksagungen","credits" => "Danksagungen",diff --git a/includes/i18n/el.php b/includes/i18n/el.phpindex 00971a0..1022a57 100644--- a/includes/i18n/el.php+++ b/includes/i18n/el.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Διαχωρισμός νοικοκυριού","payment_method_split" => "Διαχωρισμός τρόπου πληρωμής","total_cost_trend" => "Τάση συνολικού κόστους",+ "cost_vs_budget" => "Κόστος έναντι προϋπολογισμού",// About page"about_and_credits" => "Σχετικά και Credits","credits" => "Credits",diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex 6c96bd7..eda9295 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Household Split","payment_method_split" => "Payment Method Split","total_cost_trend" => "Total Cost Trend",+ "cost_vs_budget" => "Cost vs Budget",// About page"about_and_credits" => "About and Credits","credits" => "Credits",diff --git a/includes/i18n/es.php b/includes/i18n/es.phpindex 23aa727..bcfa8ca 100644--- a/includes/i18n/es.php+++ b/includes/i18n/es.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "División por Hogar","payment_method_split" => "División por Método de Pago","total_cost_trend" => "Tendencia del Costo Total",+ "cost_vs_budget" => "Costo vs Presupuesto",// About page"about_and_credits" => "Acerca de y Créditos","credits" => "Créditos",diff --git a/includes/i18n/fr.php b/includes/i18n/fr.phpindex 2d37f11..cc59eab 100644--- a/includes/i18n/fr.php+++ b/includes/i18n/fr.php@@ -118,7 +118,7 @@ $i18n = ["household_split" => "Répartition du ménage","payment_method_split" => "Répartition par méthode de paiement","total_cost_trend" => "Tendance du coût total",-+ "cost_vs_budget" => "Coût par rapport au budget",// Page À propos"about_and_credits" => "À propos et crédits","credits" => "Crédits",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex 955c556..ed75b81 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -124,6 +124,7 @@ $i18n = ["household_split" => 'Suddivisione per nucleo familiare',"payment_method_split" => 'Suddivisione per metodo di pagamento',"total_cost_trend" => 'Trend del costo totale',+ "cost_vs_budget" => 'Costo vs Budget',// About"about_and_credits" => 'Informazioni e crediti',diff --git a/includes/i18n/jp.php b/includes/i18n/jp.phpindex 98e8c3c..f35ef6b 100644--- a/includes/i18n/jp.php+++ b/includes/i18n/jp.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "世帯別","payment_method_split" => "支払い方法別","total_cost_trend" => "合計費用のトレンド",+ "cost_vs_budget" => "費用対予算",// About page"about_and_credits" => "概要とクレジット","credits" => "クレジット",diff --git a/includes/i18n/ko.php b/includes/i18n/ko.phpindex 3849186..f0f330d 100644--- a/includes/i18n/ko.php+++ b/includes/i18n/ko.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "가구별","payment_method_split" => "지불방법별","total_cost_trend" => "총 비용 추이",+ "cost_vs_budget" => "비용 vs 예산",// About page"about_and_credits" => "개요 및 크레딧","credits" => "크레딧",diff --git a/includes/i18n/nl.php b/includes/i18n/nl.phpindex 98bf8e5..e42029c 100644--- a/includes/i18n/nl.php+++ b/includes/i18n/nl.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Huishoudenverdeling","payment_method_split" => "Betaalmethodeverdeling","total_cost_trend" => "Totale kosten trend",+ "cost_vs_budget" => "Kosten vs Budget",// About page"about_and_credits" => "Over en credits","credits" => "Credits",diff --git a/includes/i18n/pl.php b/includes/i18n/pl.phpindex d40a475..dabc4ba 100644--- a/includes/i18n/pl.php+++ b/includes/i18n/pl.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Podział gospodarstwa domowego","payment_method_split" => "Podział metod płatności","total_cost_trend" => "Trend całkowitego kosztu",+ "cost_vs_budget" => "Koszt w porównaniu do budżetu",// About page"about_and_credits" => "Informacje i podziękowania","credits" => "Podziękowania",diff --git a/includes/i18n/pt.php b/includes/i18n/pt.phpindex 6e4c980..4ebad89 100644--- a/includes/i18n/pt.php+++ b/includes/i18n/pt.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Por Membro","payment_method_split" => "Por Método de Pagamento","total_cost_trend" => "Tendência de Custo Total",+ "cost_vs_budget" => "Custo vs Orçamento",// About page"about_and_credits" => "Sobre e Créditos","credits" => "Créditos",diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.phpindex 1a66cc4..a4af5eb 100644--- a/includes/i18n/pt_br.php+++ b/includes/i18n/pt_br.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Por membro","payment_method_split" => "Por método de pagamento","total_cost_trend" => "Tendência de custo total",+ "cost_vs_budget" => "Custo vs Orçamento",// About page"about_and_credits" => "Sobre e Créditos","credits" => "Créditos",diff --git a/includes/i18n/ru.php b/includes/i18n/ru.phpindex b68e642..7faac1f 100644--- a/includes/i18n/ru.php+++ b/includes/i18n/ru.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "По членам семьи","payment_method_split" => "По способам оплаты","total_cost_trend" => "Тенденция общей стоимости",+ "cost_vs_budget" => "Стоимость по сравнению с бюджетом",// About page"about_and_credits" => "О компании и авторах","credits" => "Благодарности",diff --git a/includes/i18n/sl.php b/includes/i18n/sl.phpindex 83e36a6..1cee991 100644--- a/includes/i18n/sl.php+++ b/includes/i18n/sl.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Razdelitev gospodinjstva","payment_method_split" => "Razdelitev načina plačila","total_cost_trend" => "Trend skupnih stroškov",+ "cost_vs_budget" => "Stroški v primerjavi s proračunom",// About page"about_and_credits" => "O programu in zahvale","credits" => "Zahvale",diff --git a/includes/i18n/sr.php b/includes/i18n/sr.phpindex 5cc6c8d..f546f83 100644--- a/includes/i18n/sr.php+++ b/includes/i18n/sr.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Подела по домаћинству","payment_method_split" => "Подела по начинима плаћања","total_cost_trend" => "Тренд укупних трошкова",+ "cost_vs_budget" => "Трошак у односу на буџет",// Страница о апликацији"about_and_credits" => "О апликацији и заслугама","credits" => "Заслуге",diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.phpindex c7da6d8..9fcd508 100644--- a/includes/i18n/sr_lat.php+++ b/includes/i18n/sr_lat.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Podela po domaćinstvima","payment_method_split" => "Podela po načinu plaćanja","total_cost_trend" => "Trend ukupnog troška",+ "cost_vs_budget" => "Trošak vs Budžet",// Stranica O aplikaciji"about_and_credits" => "O aplikaciji i zasluge","credits" => "Zasluge",diff --git a/includes/i18n/tr.php b/includes/i18n/tr.phpindex 45e365a..85371bb 100644--- a/includes/i18n/tr.php+++ b/includes/i18n/tr.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Hane Bölümü","payment_method_split" => "Ödeme Yöntemi Bölümü","total_cost_trend" => "Toplam Maliyet Eğilimi",+ "cost_vs_budget" => "Bütçe ile Maliyet",// About page"about_and_credits" => "Hakkında ve Teşekkürler","credits" => "Teşekkürler",diff --git a/includes/i18n/uk.php b/includes/i18n/uk.phpindex 8faf222..640d40e 100644--- a/includes/i18n/uk.php+++ b/includes/i18n/uk.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "За членами сім'ї","payment_method_split" => "За способами оплати","total_cost_trend" => "Тенденція загальної вартості",+ "cost_vs_budget" => "Вартість у порівнянні з бюджетом",// About page"about_and_credits" => "Про компанію та авторів","credits" => "Подяки",diff --git a/includes/i18n/vi.php b/includes/i18n/vi.phpindex 16c059a..ddeebce 100644--- a/includes/i18n/vi.php+++ b/includes/i18n/vi.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "Phân chia theo hộ gia đình","payment_method_split" => "Phân chia theo phương thức thanh toán","total_cost_trend" => "Xu hướng chi phí tổng cộng",+ "cost_vs_budget" => "Chi phí so với ngân sách",// About page"about_and_credits" => "Giới thiệu và cảm ơn","credits" => "Cảm ơn",diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.phpindex c84564d..d681842 100644--- a/includes/i18n/zh_cn.php+++ b/includes/i18n/zh_cn.php@@ -124,6 +124,7 @@ $i18n = ["household_split" => "家庭视图","payment_method_split" => "支付方式视图","total_cost_trend" => "总费用趋势",+ "cost_vs_budget" => "费用与预算",// 关于页面"about_and_credits" => "关于和鸣谢",diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.phpindex 6e975b6..4937f73 100644--- a/includes/i18n/zh_tw.php+++ b/includes/i18n/zh_tw.php@@ -118,6 +118,7 @@ $i18n = ["household_split" => "家庭成員分析","payment_method_split" => "付款方式分析","total_cost_trend" => "總費用趨勢",+ "cost_vs_budget" => "費用與預算比較",// 關於頁面"about_and_credits" => "關於和致謝","credits" => "致謝",diff --git a/includes/version.php b/includes/version.phpindex c486545..5da1f6f 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v2.51.1";+$version = "v2.52.0";?>\ No newline at end of filediff --git a/stats.php b/stats.phpindex 65ea780..87e121a 100644--- a/stats.php+++ b/stats.php@@ -241,6 +241,7 @@ if ($result) {}}+$showVsBudgetGraph = false;if (isset($userData['budget']) && $userData['budget'] > 0) {$budget = $userData['budget'];$budgetLeft = $budget - $totalCostPerMonth;@@ -250,6 +251,17 @@ if (isset($userData['budget']) && $userData['budget'] > 0) {if ($totalCostPerMonth > $budget) {$overBudgetAmount = $totalCostPerMonth - $budget;}+ $showVsBudgetGraph = true;+ $vsBudgetDataPoints = [+ [+ "label" => translate('budget_remaining', $i18n),+ "y" => $budgetLeft,+ ],+ [+ "label" => translate('total_cost', $i18n),+ "y" => $totalCostPerMonth,+ ],+ ];}$showCantConverErrorMessage = false;@@ -341,18 +353,18 @@ $showTotalMonthlyCostGraph = count($totalMonthlyCostDataPoints) > 1;<?phpforeach ($categories as $category) {if ($category['count'] > 0) {- if ($category['name'] == "No category") {- $category['name'] = translate("no_category", $i18n);- }- $selectedClass = '';- if (isset($_GET['category']) && $_GET['category'] == $category['id']) {- $selectedClass = 'selected';- }- ?>- <div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">- <?= $category['name'] ?>- </div>- <?php+ if ($category['name'] == "No category") {+ $category['name'] = translate("no_category", $i18n);+ }+ $selectedClass = '';+ if (isset($_GET['category']) && $_GET['category'] == $category['id']) {+ $selectedClass = 'selected';+ }+ ?>+ <div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">+ <?= $category['name'] ?>+ </div>+ <?php}}?>@@ -535,11 +547,24 @@ $showTotalMonthlyCostGraph = count($totalMonthlyCostDataPoints) > 1;}$showPaymentMethodsGraph = count($paymentMethodDataPoints) > 1;- if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodsGraph || $showTotalMonthlyCostGraph) {+ if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodsGraph || $showTotalMonthlyCostGraph || $showVsBudgetGraph) {?><h2><?= translate('split_views', $i18n) ?></h2><div class="graphs"><?php++ if ($showTotalMonthlyCostGraph) {+ ?>+ <section class="graph x2">+ <header>+ <?= translate('total_cost_trend', $i18n) ?>+ <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>+ </header>+ <canvas id="totalMonthlyCostChart" style="height: 370px; width: 100%; max-height: 370px;"></canvas>+ </section>+ <?php+ }+if ($showMemberCostGraph) {?><section class="graph">@@ -575,14 +600,13 @@ $showTotalMonthlyCostGraph = count($totalMonthlyCostDataPoints) > 1;<?php}- if ($showTotalMonthlyCostGraph) {+ if ($showVsBudgetGraph) {?><section class="graph"><header>- <?= translate('total_cost_trend', $i18n) ?>- <div class="sub-header">(<?= translate('monthly_cost', $i18n) ?>)</div>+ <?= translate('cost_vs_budget', $i18n) ?> (<?= CurrencyFormatter::format($budget, $code) ?>)</header>- <canvas id="totalMonthlyCostChart" style="height: 370px; width: 100%;"></canvas>+ <canvas id="budgetVsCostChart" style="height: 370px; width: 100%;"></canvas></section><?php}@@ -595,15 +619,16 @@ $showTotalMonthlyCostGraph = count($totalMonthlyCostDataPoints) > 1;</section><?php-if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodsGraph || $showTotalMonthlyCostGraph) {+if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodsGraph || $showTotalMonthlyCostGraph || $showVsBudgetGraph) {?><script src="scripts/libs/chart.js"></script><script type="text/javascript">window.onload = function () {+ loadLineGraph("totalMonthlyCostChart", <?php echo json_encode($totalMonthlyCostDataPoints, JSON_NUMERIC_CHECK); ?>, "<?= $code ?>", "<?= $showTotalMonthlyCostGraph ?>");loadGraph("categorySplitChart", <?php echo json_encode($categoryDataPoints, JSON_NUMERIC_CHECK); ?>, "<?= $code ?>", <?= $showCategoryCostGraph ?>);loadGraph("memberSplitChart", <?php echo json_encode($memberDataPoints, JSON_NUMERIC_CHECK); ?>, "<?= $code ?>", <?= $showMemberCostGraph ?>);loadGraph("paymentMethidSplitChart", <?php echo json_encode($paymentMethodDataPoints, JSON_NUMERIC_CHECK); ?>, "", <?= $showPaymentMethodsGraph ?>);- loadLineGraph("totalMonthlyCostChart", <?php echo json_encode($totalMonthlyCostDataPoints, JSON_NUMERIC_CHECK); ?>, "<?= $code ?>", "<?= $showTotalMonthlyCostGraph ?>");+ loadGraph("budgetVsCostChart", <?php echo json_encode($vsBudgetDataPoints, JSON_NUMERIC_CHECK); ?>, "<?= $code ?>", <?= $showVsBudgetGraph ?>);}</script><?phpdiff --git a/styles/styles.css b/styles/styles.cssindex 03152f0..1b086fc 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -2031,6 +2031,10 @@ button.dark-theme-button i {font-weight: normal;}+.graph.x2 {+ flex-basis: 100%;+}+@media (max-width: 768px) {.graph {flex-basis: 100%;