Skip to content

Commit

Permalink
Only show graphs if there's more than 1 item
Browse files Browse the repository at this point in the history
  • Loading branch information
ellite committed Nov 16, 2023
1 parent 98e97ef commit b57c258
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function getPriceConverted($price, $currency, $database) {
<h2>Split Views</h2>
<div class="graphs">
<?php

$categoryDataPoints = [];
foreach ($categoryCost as $category) {
if ($category['cost'] != 0) {
$categoryDataPoints[] = [
Expand All @@ -196,8 +196,9 @@ function getPriceConverted($price, $currency, $database) {
}
}

$showCategoryCostGraph = count($categoryCost) > 1;
$showCategoryCostGraph = count($categoryDataPoints) > 1;

$memberDataPoints = [];
foreach ($memberCost as $member) {
if ($member['cost'] != 0) {
$memberDataPoints[] = [
Expand All @@ -208,7 +209,7 @@ function getPriceConverted($price, $currency, $database) {
}
}

$showMemberCostGraph = count($memberCost) > 1;
$showMemberCostGraph = count($memberDataPoints) > 1;

if ($showMemberCostGraph) {
?>
Expand Down Expand Up @@ -238,7 +239,7 @@ function getPriceConverted($price, $currency, $database) {
</div>
</section>
<?php
if ($showCategoryCostGraph || $showMemberCostGraph || $showCostPerMonthGraph) {
if ($showCategoryCostGraph || $showMemberCostGraph) {
?>
<script src="scripts/libs/chart.js"></script>
<script type="text/javascript">
Expand Down

0 comments on commit b57c258

Please sign in to comment.