mirror of
https://github.com/YGGverse/graph-php.git
synced 2026-03-31 09:35:31 +00:00
use max value of month as 100% height
This commit is contained in:
parent
291059ea96
commit
b6d6685416
1 changed files with 8 additions and 18 deletions
|
|
@ -33,24 +33,22 @@ class Month
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNodes(string $height = 'month') : object
|
public function getNodes() : object
|
||||||
{
|
{
|
||||||
// Calculate totals
|
// Calculate max value
|
||||||
$hours = [];
|
$max = 0;
|
||||||
$month = 0;
|
|
||||||
|
|
||||||
foreach ($this->_node as $i => $day)
|
foreach ($this->_node as $i => $day)
|
||||||
{
|
{
|
||||||
foreach ($day as $l => $layer)
|
foreach ($day as $l => $layer)
|
||||||
{
|
{
|
||||||
$hours[$i][$l] = 0;
|
|
||||||
|
|
||||||
foreach ($layer as $data)
|
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
|
// Calculate column width, height, offset
|
||||||
foreach ($layer as $j => $data)
|
foreach ($layer as $j => $data)
|
||||||
{
|
{
|
||||||
switch ($height)
|
$this->_node[$i][$l][$j]['height'] = $max ? ceil($data['value'] / $max * 100) : 0;
|
||||||
{
|
|
||||||
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]['width'] = $width;
|
$this->_node[$i][$l][$j]['width'] = $width;
|
||||||
$this->_node[$i][$l][$j]['offset'] = $width * $j;
|
$this->_node[$i][$l][$j]['offset'] = $width * $j;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue