Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

Only show graphs if there's more than 1 item

elliteb57c25843bc0
diff --git a/stats.php b/stats.php
index 00f0d29..0bca08d 100644
--- a/stats.php
+++ b/stats.php
@@ -186,7 +186,7 @@ if ($result) {
<h2>Split Views</h2>
<div class="graphs">
<?php
-
+ $categoryDataPoints = [];
foreach ($categoryCost as $category) {
if ($category['cost'] != 0) {
$categoryDataPoints[] = [
@@ -196,8 +196,9 @@ if ($result) {
}
}
- $showCategoryCostGraph = count($categoryCost) > 1;
+ $showCategoryCostGraph = count($categoryDataPoints) > 1;
+ $memberDataPoints = [];
foreach ($memberCost as $member) {
if ($member['cost'] != 0) {
$memberDataPoints[] = [
@@ -208,7 +209,7 @@ if ($result) {
}
}
- $showMemberCostGraph = count($memberCost) > 1;
+ $showMemberCostGraph = count($memberDataPoints) > 1;
if ($showMemberCostGraph) {
?>
@@ -238,7 +239,7 @@ if ($result) {
</div>
</section>
<?php
- if ($showCategoryCostGraph || $showMemberCostGraph || $showCostPerMonthGraph) {
+ if ($showCategoryCostGraph || $showMemberCostGraph) {
?>
<script src="scripts/libs/chart.js"></script>
<script type="text/javascript">