Compare commits

...

7 commits
0.1.1 ... main

Author SHA1 Message Date
ghost
b6d6685416 use max value of month as 100% height 2024-01-24 03:06:03 +02:00
ghost
291059ea96 replace round to ceil 2024-01-24 02:31:13 +02:00
ghost
72ee9ec227 add height calculation modes, month by default 2024-01-24 02:25:56 +02:00
ghost
cdc2217187 update examples 2024-01-24 02:25:09 +02:00
ghost
5e50c06e0b Merge remote-tracking branch 'refs/remotes/origin/main' 2024-01-24 02:24:12 +02:00
d47081
405625337c
update preview location 2024-01-24 02:21:11 +02:00
ghost
ba577fed13 remove media files from package 2024-01-24 02:17:55 +02:00
3 changed files with 12 additions and 10 deletions

View file

@ -7,11 +7,12 @@ Build calendar graphs with unlimited chart layers
#### [Month](https://github.com/YGGverse/graph-php/blob/main/src/Calendar/Month.php)
![2 layers example](https://github.com/YGGverse/graph-php/blob/main/media/calendar/example-2-layers.png?raw=true)
![yggverse-graph-php-example](https://github.com/YGGverse/graph-php/assets/108541346/bbac7626-1f0b-476c-b154-f8a6f2933530)
##### Live examples
##### Examples
* [http://94.140.114.241/yggstate](http://94.140.114.241/yggstate)
* [YGGstate](https://github.com/YGGverse/YGGstate) - Yggdrasil Network Explorer
* [HLState](https://github.com/YGGverse/HLState) - Web Monitor for Half-Life Servers
##### Usage

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -35,18 +35,19 @@ class Month
public function getNodes() : object
{
// Calculate month totals
$total = [];
// Calculate max value
$max = 0;
foreach ($this->_node as $i => $day)
{
foreach ($day as $l => $layer)
{
$total[$i][$l] = 0;
foreach ($layer as $data)
{
$total[$i][$l] += $data['value'];
if ($data['value'] > $max)
{
$max = $data['value'];
}
}
}
}
@ -66,8 +67,8 @@ 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;
$this->_node[$i][$l][$j]['width'] = $width;
$this->_node[$i][$l][$j]['height'] = $total[$i][$l] ? ceil($data['value'] / $total[$i][$l] * 100) : 0;
$this->_node[$i][$l][$j]['offset'] = $width * $j;
}
}