From b6d6685416e2e66d1a02d09cc5c07a65e313ff62 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 03:06:03 +0200 Subject: [PATCH] use max value of month as 100% height --- src/Calendar/Month.php | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Calendar/Month.php b/src/Calendar/Month.php index 287583a..9a0bacf 100644 --- a/src/Calendar/Month.php +++ b/src/Calendar/Month.php @@ -33,24 +33,22 @@ class Month ]; } - public function getNodes(string $height = 'month') : object + public function getNodes() : object { - // Calculate totals - $hours = []; - $month = 0; + // Calculate max value + $max = 0; foreach ($this->_node as $i => $day) { foreach ($day as $l => $layer) { - $hours[$i][$l] = 0; - foreach ($layer as $data) { - $hours[$i][$l] += $data['value']; + if ($data['value'] > $max) + { + $max = $data['value']; + } } - - $month = $month + $hours[$i][$l]; } } @@ -69,15 +67,7 @@ class Month // Calculate column width, height, offset foreach ($layer as $j => $data) { - switch ($height) - { - case 'day': - $this->_node[$i][$l][$j]['height'] = $hours[$i][$l] ? ceil($data['value'] / $hours[$i][$l] * 100) : 0; - break; - default: - $this->_node[$i][$l][$j]['height'] = $month ? ceil($data['value'] * ($month / 100)) : 0; - } - + $this->_node[$i][$l][$j]['height'] = $max ? ceil($data['value'] / $max * 100) : 0; $this->_node[$i][$l][$j]['width'] = $width; $this->_node[$i][$l][$j]['offset'] = $width * $j; }