From 5875b46481d9f3303a191922f7edd03620daf254 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 9 Aug 2023 15:37:31 +0300 Subject: [PATCH 01/11] fix example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6263c18..b2c4004 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ foreach ($calendarMonth->getNodes() as $day => $node) $calendarMonth->addNode( $day, // required, number of day, on this example we are processing all of days in the initiated month rand(1, 1000), // required, set some digit value for this day and current layer - 'label 1', // optional, label text that could be displayed on element over + 'label 0', // optional, label text that could be displayed on element over 'class-name', // optional, customize output with CSS class 0 // optional, define chart layer if you want to build multiple charts in single day case // e.g. 1, 2, 3... or some keyword. first layer has 0 index by default. @@ -38,7 +38,7 @@ foreach ($calendarMonth->getNodes() as $day => $node) { // To build independent chart layer, make sure that layer attribute increased, for example to 1 $calendarMonth->addNode($day, rand(0, 1000), 'my hourly label 1, 'my-class-name-1', 1); - $calendarMonth->addNode($day, rand(0, 1000), 'my hourly label 1, 'my-class-name-1', 1); + $calendarMonth->addNode($day, rand(0, 1000), 'my hourly label 2, 'my-class-name-2', 1); } } ``` From c0969363b634c1f887ff5a8100b6aaa87f9ac8f7 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 13 Aug 2023 21:45:06 +0300 Subject: [PATCH 02/11] update readme --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2c4004..6b14610 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,17 @@ foreach ($calendarMonth->getNodes() as $day => $node) ###### Client-side -Coming soon on [YGGstate](https://github.com/YGGverse/YGGstate) or play with dump generated: + * [CSS](https://github.com/YGGverse/YGGstate/blob/main/src/public/assets/theme/default/css/yggverse/graph/calendar/month.css) + * [PHP/HTML](https://github.com/YGGverse/YGGstate/blob/main/src/public/index.php) + +To make your own implementation, play with: ``` var_dump( $calendarMonth->getNodes() ); -``` \ No newline at end of file +``` + +###### Live examples + + * [https://94.140.114.241/yggstate](https://94.140.114.241/yggstate) \ No newline at end of file From 7dca03ee52b2bfe1f14145fb805fec8da2e2f9f0 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 13 Aug 2023 21:48:07 +0300 Subject: [PATCH 03/11] update readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6b14610..7c3fe16 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,14 @@ Build calendar graphs with unlimited chart layers #### [Month](https://github.com/YGGverse/graph-php/blob/main/src/Calendar/Month.php) -##### Example - ![2 layers example](https://github.com/YGGverse/graph-php/blob/main/media/calendar/example-2-layers.png?raw=true) +##### Live examples + + * [https://94.140.114.241/yggstate](https://94.140.114.241/yggstate) + +##### Usage + ###### Server-side ``` @@ -54,8 +58,4 @@ To make your own implementation, play with: var_dump( $calendarMonth->getNodes() ); -``` - -###### Live examples - - * [https://94.140.114.241/yggstate](https://94.140.114.241/yggstate) \ No newline at end of file +``` \ No newline at end of file From a678a038948c041a7089b3551cb5829da561bce3 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 16 Aug 2023 12:37:23 +0300 Subject: [PATCH 04/11] fix example url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c3fe16..d554d03 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Build calendar graphs with unlimited chart layers ##### Live examples - * [https://94.140.114.241/yggstate](https://94.140.114.241/yggstate) + * [http://94.140.114.241/yggstate](http://94.140.114.241/yggstate) ##### Usage From 6202bc81630069775ee7ed4de253fa697bce2de8 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 9 Oct 2023 04:50:13 +0300 Subject: [PATCH 05/11] fix namespace --- src/Calendar/Month.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Calendar/Month.php b/src/Calendar/Month.php index ccb6719..fa19207 100644 --- a/src/Calendar/Month.php +++ b/src/Calendar/Month.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace YGGverse\Graph\Calendar; +namespace Yggverse\Graph\Calendar; class Month { From ba577fed139e95fc75c8124a87a1eac2340caa0e Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 02:17:55 +0200 Subject: [PATCH 06/11] remove media files from package --- media/calendar/example-2-layers.png | Bin 5033 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 media/calendar/example-2-layers.png diff --git a/media/calendar/example-2-layers.png b/media/calendar/example-2-layers.png deleted file mode 100644 index 9a5491c23543558d4d1078425e4a7005f4d98d3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5033 zcmeI0dpOkV+Q&yJE#(lERmnL*Wi64zICQ`?!blD!Mj>=?9>&aILX?P*B&RKn^EfQY zLK9_4$YD&3LuS$t6JwNNa+sO-nRl&s@3-q(d+&8!```VCxh`}4e)BxfeSh!I{k@+= zdpnqf_#SZx1R?=HW#IsUh~$Akvn`v!H_k3SA0ZIgAh^YG$B10kcu(M7ZeGWizI$zA zX)>0bGM1XZD4h=ZU`a070f)3%#;OF!o$4=^xN{gghC`T62foqdl30b7WIYM{q7l)Q zTEDHLW78)uY1Z#QQ+W9-;uGceWYF@5+r;rx#okQlgHOB-u{V|VS3kq<1oqxj$@A9T zJvTou-a)A7$x&nqtn;5d3<=FzTA#b;c`0=h1R*lNHT8l$b!aH=HZ)F-6L>^a46#abxdV zoiqq|Z%=R_wBfRny`Ow!twbSZV`?wp*QreH>b zabAjN?ZX%AQ##k8qs``ORZ7TyGkItlnQ%Ib^FFjM-qgDo2*>N;|@a@}VnM8}>BFiq}{(SQ>>T^Gk>+r zx9-)3u}i6Os-L085!iJe8}CwRuVnc8=+UDn-fGz3Y?%9t$n%}vx^rnNMHJ>tDt^5P ziJ96t{v2~;E?A|^p=`$2d@XzP=FOb?>L^=TSy|YqB-!XPc%L(EE;vtL|76gnus@_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X@`$ zUf0?7Z36@8;O0R$dmA;T&{1oD-y-m+JCfQRtEnU1Mwg&aC|D1aATXVY7LUA7Vw{X=H@!^(cxjkuHpqz;AMGhTzwN0dBBwcR=Cjk#>dCgCK8B5;=PhP zDUMo%+S;Fqm6d)#1KittHQE+Ugrl~dokI6=%8on>6=iA|u45sjF*h8IPQ9$esYX_7 zXIcmQbqv##ZK+|PTYxJJ$)!_Lh{FYa*8&3U>gwu3s_AX>2K)sa8k;{2 zhJdfQpbcQ$79!TjXr+Im8)bZm&Yi*_*?!$ZuR0b6Y-3PAvg_l=$4%o^u}bzpE8rRh zr2J7&ao5x@;L8D~p3ZJlWstdsu|e?Mu3fv%ab=&VJC*g$yxFV1muhMb*RSAScCtEW17-%QAu$>&QqK%N&;E5@pKQ5g9 dEr0}4oI>>tV&B>{z!e+>ZfR#xb>d>|{{Ux*D{24$ From 405625337cfad7d373cf27c8fb362e959fc4408b Mon Sep 17 00:00:00 2001 From: d47081 <108541346+d47081@users.noreply.github.com> Date: Wed, 24 Jan 2024 02:21:11 +0200 Subject: [PATCH 07/11] update preview location --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d554d03..5e25ad4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ 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 @@ -58,4 +58,4 @@ To make your own implementation, play with: var_dump( $calendarMonth->getNodes() ); -``` \ No newline at end of file +``` From cdc2217187093d0bf32653ab9f5eccc6d31826fe Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 02:25:09 +0200 Subject: [PATCH 08/11] update examples --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e25ad4..c0d7d0b 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ Build calendar graphs with unlimited chart layers ![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 From 72ee9ec227651150f5f4529dcf5d91fce0af7416 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 02:25:56 +0200 Subject: [PATCH 09/11] add height calculation modes, month by default --- src/Calendar/Month.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Calendar/Month.php b/src/Calendar/Month.php index fa19207..2ae837e 100644 --- a/src/Calendar/Month.php +++ b/src/Calendar/Month.php @@ -33,21 +33,24 @@ class Month ]; } - public function getNodes() : object + public function getNodes(string $height = 'month') : object { - // Calculate month totals - $total = []; + // Calculate totals + $hours = []; + $month = 0; foreach ($this->_node as $i => $day) { foreach ($day as $l => $layer) { - $total[$i][$l] = 0; + $hours[$i][$l] = 0; foreach ($layer as $data) { - $total[$i][$l] += $data['value']; + $hours[$i][$l] += $data['value']; } + + $month = $month + $hours[$i][$l]; } } @@ -66,8 +69,16 @@ 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 ? round($data['value'] * ($month / 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; } } From 291059ea964dc533599d8aca689dd3c637e98d60 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 02:31:13 +0200 Subject: [PATCH 10/11] replace round to ceil --- src/Calendar/Month.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Calendar/Month.php b/src/Calendar/Month.php index 2ae837e..287583a 100644 --- a/src/Calendar/Month.php +++ b/src/Calendar/Month.php @@ -75,7 +75,7 @@ class Month $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]['height'] = $month ? ceil($data['value'] * ($month / 100)) : 0; } $this->_node[$i][$l][$j]['width'] = $width; From b6d6685416e2e66d1a02d09cc5c07a65e313ff62 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Jan 2024 03:06:03 +0200 Subject: [PATCH 11/11] 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; }