Split all files mith multiple classes into multiple files

This commit is contained in:
2022-11-25 21:54:30 +01:00
parent 94deb06f52
commit f2444f0247
20 changed files with 3285 additions and 0 deletions

111
src/GraphAxisHorizontal.php Normal file
View File

@@ -0,0 +1,111 @@
<?php
/** DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework;
/** The graph Axis Horizontal class */
class GraphAxisHorizontal extends GraphAxisGeneral
{
/** Calculate the position in pixels for a value
* If the value is out of range, return null to not draw the point
* @param string|float|integer $value The value to position
*/
public function position($value)
{
if ($value === null) {
return null;
}
if (! is_numeric($value) && ! is_string($value)) {
throw new \Exception(dgettext(
"domframework",
"Invalid value provided to graph Axis for position"
) . " " .
get_class($this), 406);
}
if ($this->numerical === null) {
throw new \Exception(dgettext(
"domframework",
"No numerical type defined for Axis"
) . " " . get_class($this), 406);
}
if ($this->numerical) {
// Numerical axis, use a standard scale
if ($value < $this->min || $value > $this->max) {
return null;
}
if (($this->max - $this->min) == 0) {
$dividor = 1;
} else {
$dividor = ($this->max - $this->min);
}
$scale = ($value - $this->min) / $dividor;
return intval($this->left + $scale * ($this->right - $this->left));
} else {
// Label axis, count them
if (! is_array($this->data)) {
throw new \Exception(dgettext(
"domframework",
"No data defined for Axis"
) . " " . get_class($this), 406);
}
$pos = array_search($value, $this->data);
if ($pos === false) {
return null;
}
$width = ($this->right - $this->left) / count($this->data);
return intval($this->left + $width * $pos + $width / 2);
}
}
/** Calculate the positionMin, used for labeled axies
* If the value is out of range, return null to not draw the point
* @param string|float|integer $value The value to position
*/
public function positionMin($value)
{
if ($this->numerical) {
return $posCenter;
}
if (! is_array($this->data)) {
throw new \Exception(dgettext(
"domframework",
"No data defined for Axis"
) . " " . get_class($this), 406);
}
$pos = array_search($value, $this->data);
if ($pos === false) {
return null;
}
$width = ($this->right - $this->left) / count($this->data);
return intval($this->left + $width * $pos);
}
/** Calculate the positionMax, used for labeled axies
* If the value is out of range, return null to not draw the point
* @param string|float|integer $value The value to position
*/
public function positionMax($value)
{
$posCenter = $this->position($value);
if ($this->numerical) {
return $posCenter;
}
if (! is_array($this->data)) {
throw new \Exception(dgettext(
"domframework",
"No data defined for Axis"
) . " " . get_class($this), 406);
}
$pos = array_search($value, $this->data);
if ($pos === false) {
return null;
}
$width = ($this->right - $this->left) / count($this->data);
return intval($this->left + $width * $pos + $width);
}
}