mirror of
https://github.com/YGGverse/graph-php.git
synced 2026-04-01 18:15:30 +00:00
Compare commits
No commits in common. "main" and "0.2.0" have entirely different histories.
1 changed files with 18 additions and 8 deletions
|
|
@ -33,22 +33,24 @@ class Month
|
|||
];
|
||||
}
|
||||
|
||||
public function getNodes() : object
|
||||
public function getNodes(string $height = 'month') : object
|
||||
{
|
||||
// Calculate max value
|
||||
$max = 0;
|
||||
// Calculate totals
|
||||
$hours = [];
|
||||
$month = 0;
|
||||
|
||||
foreach ($this->_node as $i => $day)
|
||||
{
|
||||
foreach ($day as $l => $layer)
|
||||
{
|
||||
$hours[$i][$l] = 0;
|
||||
|
||||
foreach ($layer as $data)
|
||||
{
|
||||
if ($data['value'] > $max)
|
||||
{
|
||||
$max = $data['value'];
|
||||
}
|
||||
$hours[$i][$l] += $data['value'];
|
||||
}
|
||||
|
||||
$month = $month + $hours[$i][$l];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +69,15 @@ class Month
|
|||
// Calculate column width, height, offset
|
||||
foreach ($layer as $j => $data)
|
||||
{
|
||||
$this->_node[$i][$l][$j]['height'] = $max ? ceil($data['value'] / $max * 100) : 0;
|
||||
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 ? round($data['value'] * ($month / 100)) : 0;
|
||||
}
|
||||
|
||||
$this->_node[$i][$l][$j]['width'] = $width;
|
||||
$this->_node[$i][$l][$j]['offset'] = $width * $j;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue