From 51069e46d4b45164ec3e49c79ed30f35ed0474f3 Mon Sep 17 00:00:00 2001 From: Mathew Date: Sun, 24 May 2026 21:59:51 +1000 Subject: [PATCH] dont use constant of VOID --- constants.php | 2 +- resources/doc/filled_step.md | 2 +- resources/doc/line.md | 2 +- resources/doc/step.md | 2 +- src/BaseDraw.php | 34 +++---- src/Chart/Bubble.php | 8 +- src/Chart/Indicator.php | 2 +- src/Chart/Pie.php | 26 ++--- src/Chart/Radar.php | 24 ++--- src/Chart/Scatter.php | 28 +++--- src/Data.php | 50 +++++----- src/Draw.php | 172 +++++++++++++++++----------------- src/Image.php | 12 +-- tests/unit/BarTest.php | 4 +- tests/unit/FilledStepTest.php | 4 +- tests/unit/LineTest.php | 4 +- tests/unit/StepTest.php | 4 +- 17 files changed, 190 insertions(+), 190 deletions(-) diff --git a/constants.php b/constants.php index 0c48fe7..866b6cd 100644 --- a/constants.php +++ b/constants.php @@ -43,7 +43,7 @@ define("ABSOLUTE_MIN", -10000000000000); define("ABSOLUTE_MAX", 10000000000000); /* Replacement to the PHP null keyword */ -define("VOID", 0.123456789); +define("VOID_NULL", 0.123456789); /* Euro symbol for GD fonts */ define("EURO_SYMBOL", "€"); diff --git a/resources/doc/filled_step.md b/resources/doc/filled_step.md index e17eeea..86941f4 100644 --- a/resources/doc/filled_step.md +++ b/resources/doc/filled_step.md @@ -10,7 +10,7 @@ use CpChart\Image; /* Create and populate the Data object */ $data = new Data(); -$data->addPoints([-4, 2, VOID, 12, 8, 3], "Probe 1"); +$data->addPoints([-4, 2, VOID_NULL, 12, 8, 3], "Probe 1"); $data->addPoints([3, 12, 15, 8, 5, -5], "Probe 2"); $data->addPoints([2, 7, 5, 18, 19, 22], "Probe 3"); $data->setSerieTicks("Probe 2", 4); diff --git a/resources/doc/line.md b/resources/doc/line.md index 083a3d7..94f1eb8 100644 --- a/resources/doc/line.md +++ b/resources/doc/line.md @@ -10,7 +10,7 @@ use CpChart\Image; /* Build a dataset */ $data = new Data(); -$data->addPoints([-4, VOID, VOID, 12, 8, 3], "Probe 1"); +$data->addPoints([-4, VOID_NULL, VOID_NULL, 12, 8, 3], "Probe 1"); $data->addPoints([3, 12, 15, 8, 5, -5], "Probe 2"); $data->addPoints([2, 7, 5, 18, 19, 22], "Probe 3"); $data->setSerieTicks("Probe 2", 4); diff --git a/resources/doc/step.md b/resources/doc/step.md index ef094b9..b9194b4 100644 --- a/resources/doc/step.md +++ b/resources/doc/step.md @@ -10,7 +10,7 @@ use CpChart\Image; /* Create and populate the Data object */ $data = new Data(); -$data->addPoints([-4, VOID, VOID, 12, 8, 3], "Probe 1"); +$data->addPoints([-4, VOID_NULL, VOID_NULL, 12, 8, 3], "Probe 1"); $data->addPoints([3, 12, 15, 8, 5, -5], "Probe 2"); $data->addPoints([2, 7, 5, 18, 19, 22], "Probe 3"); $data->setSerieTicks("Probe 2", 4); diff --git a/src/BaseDraw.php b/src/BaseDraw.php index 531f798..a5045e1 100644 --- a/src/BaseDraw.php +++ b/src/BaseDraw.php @@ -33,7 +33,7 @@ use const TEXT_ALIGN_MIDDLELEFT; use const TEXT_ALIGN_MIDDLERIGHT; use const TEXT_ALIGN_TOPMIDDLE; -use const VOID; +use const VOID_NULL; /** * This class exists only to try and reduce the number of methods and properties @@ -986,16 +986,16 @@ public function scaleComputeY($Values, array $Option = [], $ReturnOnly0Height = if ($ReturnOnly0Height) { foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $Step * $Value; } } } else { foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $this->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"] @@ -1011,16 +1011,16 @@ public function scaleComputeY($Values, array $Option = [], $ReturnOnly0Height = if ($ReturnOnly0Height) { foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $Step * $Value; } } } else { foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $this->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] @@ -1043,7 +1043,7 @@ public function scaleComputeY($Values, array $Option = [], $ReturnOnly0Height = */ public function scaleFormat($Value, $Mode = null, $Format = null, $Unit = null) { - if ($Value == VOID) { + if ($Value == VOID_NULL) { return ""; } @@ -1185,10 +1185,10 @@ public function writeBounds($Type = BOUND_BOTH, $Format = null) $MinValue = $this->DataSet->getMin($SerieName); $MaxValue = $this->DataSet->getMax($SerieName); - $MinPos = VOID; - $MaxPos = VOID; + $MinPos = VOID_NULL; + $MaxPos = VOID_NULL; foreach ($Serie["Data"] as $Key => $Value) { - if ($Value == $MinValue && $MinPos == VOID) { + if ($Value == $MinValue && $MinPos == VOID_NULL) { $MinPos = $Key; } if ($Value == $MaxValue) { @@ -1518,7 +1518,7 @@ public function writeLabel($SeriesName, $Indexes, array $Format = []) $SerieOffset = 0; } $Value = $Data["Series"][$SerieName]["Data"][$Index]; - if ($Value == VOID) { + if ($Value == VOID_NULL) { $Value = "NaN"; } @@ -1544,7 +1544,7 @@ public function writeLabel($SeriesName, $Indexes, array $Format = []) ) { if ( isset($Data["Series"][$Name]["Data"][$Index]) - && $Data["Series"][$Name]["Data"][$Index] != VOID + && $Data["Series"][$Name]["Data"][$Index] != VOID_NULL ) { if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+") { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; @@ -1690,7 +1690,7 @@ public function writeLabel($SeriesName, $Indexes, array $Format = []) } else { $Caption = $this->scaleFormat($Value, $AxisMode, $AxisFormat, $AxisUnit); } - if ($Value == VOID) { + if ($Value == VOID_NULL) { $Value = "NaN"; } @@ -1711,7 +1711,7 @@ public function writeLabel($SeriesName, $Indexes, array $Format = []) ) { if ( isset($Data["Series"][$Name]["Data"][$Index]) - && $Data["Series"][$Name]["Data"][$Index] != VOID + && $Data["Series"][$Name]["Data"][$Index] != VOID_NULL ) { if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+") { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; diff --git a/src/Chart/Bubble.php b/src/Chart/Bubble.php index 0c725ee..11e7750 100644 --- a/src/Chart/Bubble.php +++ b/src/Chart/Bubble.php @@ -118,7 +118,7 @@ public function resetSeriesColors() public function drawBubbleChart($DataSeries, $WeightSeries, $Format = "") { - $ForceAlpha = isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : VOID; + $ForceAlpha = isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : VOID_NULL; $DrawBorder = isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : true; $BorderWidth = isset($Format["BorderWidth"]) ? $Format["BorderWidth"] : 1; $Shape = isset($Format["Shape"]) ? $Format["Shape"] : BUBBLE_SHAPE_ROUND; @@ -174,7 +174,7 @@ public function drawBubbleChart($DataSeries, $WeightSeries, $Format = "") "Alpha" => $Palette[$Key]["Alpha"] ]; - if ($ForceAlpha != VOID) { + if ($ForceAlpha != VOID_NULL) { $Color["Alpha"] = $ForceAlpha; } @@ -185,7 +185,7 @@ public function drawBubbleChart($DataSeries, $WeightSeries, $Format = "") $BorderG = $Palette[$Key]["G"] + $Surrounding; $BorderB = $Palette[$Key]["B"] + $Surrounding; } - if ($ForceAlpha != VOID) { + if ($ForceAlpha != VOID_NULL) { $BorderAlpha = $ForceAlpha / 2; } $BorderColor = [ @@ -206,7 +206,7 @@ public function drawBubbleChart($DataSeries, $WeightSeries, $Format = "") $Color["BorderG"] = $BorderG; $Color["BorderB"] = $BorderB; } - if ($ForceAlpha != VOID) { + if ($ForceAlpha != VOID_NULL) { $Color["BorderAlpha"] = $ForceAlpha / 2; } } diff --git a/src/Chart/Indicator.php b/src/Chart/Indicator.php index 68e673e..24813e2 100644 --- a/src/Chart/Indicator.php +++ b/src/Chart/Indicator.php @@ -28,7 +28,7 @@ public function __construct(Image $pChartObject) */ public function draw($X, $Y, $Width, $Height, array $Format = []) { - $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; + $Values = isset($Format["Values"]) ? $Format["Values"] : VOID_NULL; $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : null; $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; diff --git a/src/Chart/Pie.php b/src/Chart/Pie.php index 1dfa0f7..f097c84 100644 --- a/src/Chart/Pie.php +++ b/src/Chart/Pie.php @@ -31,7 +31,7 @@ use const TEXT_ALIGN_MIDDLERIGHT; use const TEXT_ALIGN_TOPLEFT; use const TEXT_ALIGN_TOPRIGHT; -use const VOID; +use const VOID_NULL; class Pie { @@ -1807,8 +1807,8 @@ public function draw3DRing($X, $Y, array $Format = []) } $Step = (360 / (2 * PI * $OuterRadius)) / 2; - $OutX1 = VOID; - $OutY1 = VOID; + $OutX1 = VOID_NULL; + $OutY1 = VOID_NULL; for ($i = $Offset; $i >= $EndAngle; $i = $i - $Step) { $Xc = cos(($i - 90) * PI / 180) * ($OuterRadius + $DataGapRadius - 2) + $X; $Yc = sin(($i - 90) * PI / 180) * ($OuterRadius + $DataGapRadius - 2) * $SkewFactor + $Y; @@ -1822,7 +1822,7 @@ public function draw3DRing($X, $Y, array $Format = []) $Yc = sin(($i - 90) * PI / 180) * ($OuterRadius + $DataGapRadius) * $SkewFactor + $Y; $this->pChartObject->drawAntialiasPixel($Xc, $Yc, $Settings); - if ($OutX1 == VOID) { + if ($OutX1 == VOID_NULL) { $OutX1 = $Xc; $OutY1 = $Yc; } @@ -1850,12 +1850,12 @@ public function draw3DRing($X, $Y, array $Format = []) $OutX2 = $Xc; $OutY2 = $Yc; - $Slices[$Slice]["Angle"][] = VOID; + $Slices[$Slice]["Angle"][] = VOID_NULL; $Lasti = $i; $Step = (360 / (2 * PI * $InnerRadius)) / 2; - $InX1 = VOID; - $InY1 = VOID; + $InX1 = VOID_NULL; + $InY1 = VOID_NULL; for ($i = $EndAngle; $i <= $Offset; $i = $i + $Step) { $Xc = cos(($i - 90) * PI / 180) * ($InnerRadius + $DataGapRadius - 1) + $X; $Yc = sin(($i - 90) * PI / 180) * ($InnerRadius + $DataGapRadius - 1) * $SkewFactor + $Y; @@ -1865,7 +1865,7 @@ public function draw3DRing($X, $Y, array $Format = []) $Yc = sin(($i - 90) * PI / 180) * ($InnerRadius + $DataGapRadius) * $SkewFactor + $Y; $Slices[$Slice]["AA"][] = [$Xc, $Yc]; - if ($InX1 == VOID) { + if ($InX1 == VOID_NULL) { $InX1 = $Xc; $InY1 = $Yc; } @@ -1945,7 +1945,7 @@ public function draw3DRing($X, $Y, array $Format = []) $StartAngle = $Plots["Angle"][0]; foreach ($Plots["Angle"] as $Key => $Angle) { - if ($Angle == VOID) { + if ($Angle == VOID_NULL) { $EndAngle = $Plots["Angle"][$Key - 1]; } } @@ -1997,7 +1997,7 @@ public function draw3DRing($X, $Y, array $Format = []) $InnerPlotsA = []; $InnerPlotsB = []; foreach ($Plots["Angle"] as $ID => $Angle) { - if ($Angle == VOID) { + if ($Angle == VOID_NULL) { $Outer = false; $Inner = true; } elseif ($Inner && ($Angle < 90 || $Angle > 270) && isset($Plots["BottomPoly"][$ID * 2])) { @@ -2027,7 +2027,7 @@ public function draw3DRing($X, $Y, array $Format = []) $StartAngle = $Plots["Angle"][0]; foreach ($Plots["Angle"] as $Key => $Angle) { - if ($Angle == VOID) { + if ($Angle == VOID_NULL) { $EndAngle = $Plots["Angle"][$Key - 1]; } } @@ -2072,7 +2072,7 @@ public function draw3DRing($X, $Y, array $Format = []) $StartAngle = $Plots["Angle"][0]; foreach ($Plots["Angle"] as $Key => $Angle) { - if ($Angle == VOID) { + if ($Angle == VOID_NULL) { $EndAngle = $Plots["Angle"][$Key - 1]; } } @@ -2113,7 +2113,7 @@ public function draw3DRing($X, $Y, array $Format = []) $InnerPlotsA = []; $InnerPlotsB = []; foreach ($Plots["Angle"] as $ID => $Angle) { - if ($Angle == VOID) { + if ($Angle == VOID_NULL) { $Outer = false; $Inner = true; } elseif ($Outer && ($Angle > 90 && $Angle < 270) && isset($Plots["BottomPoly"][$ID * 2])) { diff --git a/src/Chart/Radar.php b/src/Chart/Radar.php index 4225015..421f878 100644 --- a/src/Chart/Radar.php +++ b/src/Chart/Radar.php @@ -22,7 +22,7 @@ public function drawRadar(Image $Object, Data $Values, array $Format = []) { $this->pChartObject = $Object; - $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID; + $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID_NULL; $AxisR = isset($Format["AxisR"]) ? $Format["AxisR"] : 60; $AxisG = isset($Format["AxisG"]) ? $Format["AxisG"] : 60; $AxisB = isset($Format["AxisB"]) ? $Format["AxisB"] : 60; @@ -42,9 +42,9 @@ public function drawRadar(Image $Object, Data $Values, array $Format = []) ; $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 4; $OuterBubbleRadius = isset($Format["OuterBubbleRadius"]) ? $Format["OuterBubbleRadius"] : 2; - $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID; - $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID; - $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID; + $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID_NULL; + $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID_NULL; + $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID_NULL; $OuterBubbleAlpha = isset($Format["OuterBubbleAlpha"]) ? $Format["OuterBubbleAlpha"] : 100; $InnerBubbleR = isset($Format["InnerBubbleR"]) ? $Format["InnerBubbleR"] : 255; $InnerBubbleG = isset($Format["InnerBubbleG"]) ? $Format["InnerBubbleG"] : 255; @@ -115,7 +115,7 @@ public function drawRadar(Image $Object, Data $Values, array $Format = []) } /* Determine the scale if set to automatic */ if ($SegmentHeight == SEGMENT_HEIGHT_AUTO) { - if ($FixedMax != VOID) { + if ($FixedMax != VOID_NULL) { $Max = $FixedMax; } else { $Max = 0; @@ -501,7 +501,7 @@ public function drawRadar(Image $Object, Data $Values, array $Format = []) "B" => $InnerBubbleB, "Alpha" => $InnerBubbleAlpha ]; - if ($OuterBubbleR != VOID) { + if ($OuterBubbleR != VOID_NULL) { $OuterColor = [ "R" => $OuterBubbleR, "G" => $OuterBubbleG, @@ -603,7 +603,7 @@ public function drawPolar(Image $Object, Data $Values, array $Format = []) { $this->pChartObject = $Object; - $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID; + $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID_NULL; $AxisR = isset($Format["AxisR"]) ? $Format["AxisR"] : 60; $AxisG = isset($Format["AxisG"]) ? $Format["AxisG"] : 60; $AxisB = isset($Format["AxisB"]) ? $Format["AxisB"] : 60; @@ -625,9 +625,9 @@ public function drawPolar(Image $Object, Data $Values, array $Format = []) ; $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 4; $OuterBubbleRadius = isset($Format["OuterBubbleRadius"]) ? $Format["OuterBubbleRadius"] : 2; - $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID; - $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID; - $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID; + $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID_NULL; + $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID_NULL; + $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID_NULL; $OuterBubbleAlpha = isset($Format["OuterBubbleAlpha"]) ? $Format["OuterBubbleAlpha"] : 100; $InnerBubbleR = isset($Format["InnerBubbleR"]) ? $Format["InnerBubbleR"] : 255; $InnerBubbleG = isset($Format["InnerBubbleG"]) ? $Format["InnerBubbleG"] : 255; @@ -701,7 +701,7 @@ public function drawPolar(Image $Object, Data $Values, array $Format = []) /* Determine the scale if set to automatic */ if ($SegmentHeight == SEGMENT_HEIGHT_AUTO) { - if ($FixedMax != VOID) { + if ($FixedMax != VOID_NULL) { $Max = $FixedMax; } else { $Max = 0; @@ -989,7 +989,7 @@ public function drawPolar(Image $Object, Data $Values, array $Format = []) "B" => $InnerBubbleB, "Alpha" => $InnerBubbleAlpha ]; - if ($OuterBubbleR != VOID) { + if ($OuterBubbleR != VOID_NULL) { $OuterColor = [ "R" => $OuterBubbleR, "G" => $OuterBubbleG, diff --git a/src/Chart/Scatter.php b/src/Chart/Scatter.php index 3234239..0452eee 100644 --- a/src/Chart/Scatter.php +++ b/src/Chart/Scatter.php @@ -928,7 +928,7 @@ public function drawScatterPlotChart($Format = null) $X = $Value; $Y = $PosArrayY[$Key]; - if ($X != VOID && $Y != VOID) { + if ($X != VOID_NULL && $Y != VOID_NULL) { $RealValue = sprintf( "%s / %s", round($Data["Series"][$Series["X"]]["Data"][$Key], 2), @@ -1053,13 +1053,13 @@ public function drawScatterLineChart($Format = null) $Color["Weight"] = $Weight; } - $LastX = VOID; - $LastY = VOID; + $LastX = VOID_NULL; + $LastY = VOID_NULL; foreach ($PosArrayX as $Key => $Value) { $X = $Value; $Y = $PosArrayY[$Key]; - if ($X != VOID && $Y != VOID) { + if ($X != VOID_NULL && $Y != VOID_NULL) { $RealValue = sprintf( "%s / %s", round($Data["Series"][$Series["X"]]["Data"][$Key], 2), @@ -1080,7 +1080,7 @@ public function drawScatterLineChart($Format = null) } } - if ($X != VOID && $Y != VOID && $LastX != VOID && $LastY != VOID) { + if ($X != VOID_NULL && $Y != VOID_NULL && $LastX != VOID_NULL && $LastY != VOID_NULL) { $this->pChartObject->drawLine($LastX, $LastY, $X, $Y, $Color); } $LastX = $X; @@ -1148,8 +1148,8 @@ public function drawScatterSplineChart(array $Format = []) $SplineSettings["Weight"] = $Weight; } - $LastX = VOID; - $LastY = VOID; + $LastX = VOID_NULL; + $LastY = VOID_NULL; $WayPoints = []; $Forces = []; foreach ($PosArrayX as $Key => $Value) { @@ -1157,7 +1157,7 @@ public function drawScatterSplineChart(array $Format = []) $Y = $PosArrayY[$Key]; $Force = $this->pChartObject->getLength($LastX, $LastY, $X, $Y) / 5; - if ($X != VOID && $Y != VOID) { + if ($X != VOID_NULL && $Y != VOID_NULL) { $RealValue = sprintf( "%s / %s", round($Data["Series"][$Series["X"]]["Data"][$Key], 2), @@ -1178,12 +1178,12 @@ public function drawScatterSplineChart(array $Format = []) } } - if ($X != VOID && $Y != VOID) { + if ($X != VOID_NULL && $Y != VOID_NULL) { $WayPoints[] = [$X, $Y]; $Forces[] = $Force; } - if ($Y == VOID || $X == VOID) { + if ($Y == VOID_NULL || $X == VOID_NULL) { $SplineSettings["Forces"] = $Forces; $this->pChartObject->drawSpline($WayPoints, $SplineSettings); $WayPoints = []; @@ -1222,8 +1222,8 @@ public function getPosArray($Values, $AxisID) $Result = []; foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] @@ -1240,8 +1240,8 @@ public function getPosArray($Values, $AxisID) $Result = []; foreach ($Values as $Key => $Value) { - if ($Value == VOID) { - $Result[] = VOID; + if ($Value == VOID_NULL) { + $Result[] = VOID_NULL; } else { $Result[] = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"] diff --git a/src/Data.php b/src/Data.php index 5886ca7..9ff791c 100644 --- a/src/Data.php +++ b/src/Data.php @@ -12,7 +12,7 @@ use const AXIS_POSITION_LEFT; use const AXIS_Y; use const SERIE_SHAPE_FILLEDCIRCLE; -use const VOID; +use const VOID_NULL; /** * @phpstan-type FormatArray array{ R?: int, G?: int, B?: int, Alpha?: int } @@ -78,9 +78,9 @@ public function addPoints($Values, $SerieName = "Serie1"): ?int $this->Data["Series"][$SerieName]["Data"][] = $Values; } - if ($Values != VOID) { + if ($Values != VOID_NULL) { /** @var list $StrippedData */ - $StrippedData = $this->stripVOID($this->Data["Series"][$SerieName]["Data"]); + $StrippedData = $this->stripVOID_NULL($this->Data["Series"][$SerieName]["Data"]); if (empty($StrippedData)) { $this->Data["Series"][$SerieName]["Max"] = 0; $this->Data["Series"][$SerieName]["Min"] = 0; @@ -95,11 +95,11 @@ public function addPoints($Values, $SerieName = "Serie1"): ?int } /** - * Strip VOID values + * Strip VOID_NULL values * @param float|int|string|null|array $values * @return array */ - public function stripVOID($values) + public function stripVOID_NULL($values) { if (is_array($values) === false) { return []; @@ -107,7 +107,7 @@ public function stripVOID($values) $filteredValues = array_filter( $values, - static fn($value): bool => $value != VOID + static fn($value): bool => $value != VOID_NULL ); return array_values($filteredValues); @@ -550,7 +550,7 @@ public function getSerieAverage($Serie) return null; } - $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); + $SerieData = $this->stripVOID_NULL($this->Data["Series"][$Serie]["Data"]); return array_sum($SerieData) / sizeof($SerieData); } @@ -562,7 +562,7 @@ public function getSerieAverage($Serie) public function getGeometricMean($Serie) { if (isset($this->Data["Series"][$Serie])) { - $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); + $SerieData = $this->stripVOID_NULL($this->Data["Series"][$Serie]["Data"]); $Seriesum = 1; foreach ($SerieData as $Value) { $Seriesum = $Seriesum * $Value; @@ -584,7 +584,7 @@ public function getHarmonicMean($Serie) return null; } - $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); + $SerieData = $this->stripVOID_NULL($this->Data["Series"][$Serie]["Data"]); $Seriesum = 0; /** @var float|int $Value */ foreach ($SerieData as $Value) { @@ -606,7 +606,7 @@ public function getStandardDeviation($Serie) } $Average = $this->getSerieAverage($Serie); - $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); + $SerieData = $this->stripVOID_NULL($this->Data["Series"][$Serie]["Data"]); $DeviationSum = 0; /** @var float|int $Value */ @@ -649,7 +649,7 @@ public function getSerieMedian($Serie) return null; } - $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); + $SerieData = $this->stripVOID_NULL($this->Data["Series"][$Serie]["Data"]); sort($SerieData); $SerieCenter = (int) floor(sizeof($SerieData) / 2); @@ -1138,7 +1138,7 @@ public function normalize($NormalizationFactor = 100, $UnitChange = null, $Round $Factor = 0; foreach ($SelectedSeries as $Key => $SerieName) { $Value = $this->Data["Series"][$SerieName]["Data"][$i]; - if ($Value != VOID) { + if ($Value != VOID_NULL) { $Factor = $Factor + abs($Value); } } @@ -1149,10 +1149,10 @@ public function normalize($NormalizationFactor = 100, $UnitChange = null, $Round foreach ($SelectedSeries as $Key => $SerieName) { $Value = $this->Data["Series"][$SerieName]["Data"][$i]; - if ($Value != VOID && $Factor != $NormalizationFactor) { + if ($Value != VOID_NULL && $Factor != $NormalizationFactor) { $this->Data["Series"][$SerieName]["Data"][$i] = round(abs($Value) * $Factor, $Round); - } elseif ($Value == VOID || $Value == 0) { - $this->Data["Series"][$SerieName]["Data"][$i] = VOID; + } elseif ($Value == VOID_NULL || $Value == 0) { + $this->Data["Series"][$SerieName]["Data"][$i] = VOID_NULL; } elseif ($Factor == $NormalizationFactor) { $this->Data["Series"][$SerieName]["Data"][$i] = $NormalizationFactor; } @@ -1162,7 +1162,7 @@ public function normalize($NormalizationFactor = 100, $UnitChange = null, $Round foreach ($SelectedSeries as $Key => $SerieName) { /** @var non-empty-list $strippedData */ - $strippedData = $this->stripVOID( + $strippedData = $this->stripVOID_NULL( $this->Data["Series"][$SerieName]["Data"] ); $this->Data["Series"][$SerieName]["Max"] = max($strippedData); @@ -1274,30 +1274,30 @@ public function createFunctionSerie($SerieName, $Formula = "", array $Options = ; if (@eval($Expression) === false) { - $return = VOID; + $return = VOID_NULL; } if (isset($return) === false) { - $return = VOID; + $return = VOID_NULL; } if ($return == "!") { - $return = VOID; + $return = VOID_NULL; } else { $returnAsString = (string) $return; $return = $this->right($returnAsString, strlen($returnAsString) - 1); } if ($return == "NAN") { - $return = VOID; + $return = VOID_NULL; } if ($return == "INF") { - $return = VOID; + $return = VOID_NULL; } if ($return == "-INF") { - $return = VOID; + $return = VOID_NULL; } $Abscissa[] = $i; @@ -1332,15 +1332,15 @@ public function negateValues($Series) $Data = []; foreach ($this->Data["Series"][$SerieName]["Data"] as $Key => $Value) { - if ($Value == VOID) { - $Data[] = VOID; + if ($Value == VOID_NULL) { + $Data[] = VOID_NULL; } else { $Data[] = -$Value; } } /** @var non-empty-list $strippedData */ - $strippedData = $this->stripVOID( + $strippedData = $this->stripVOID_NULL( $this->Data["Series"][$SerieName]["Data"] ); diff --git a/src/Draw.php b/src/Draw.php index a351cf8..e9fd363 100644 --- a/src/Draw.php +++ b/src/Draw.php @@ -5188,7 +5188,7 @@ public function drawPlotChart(array $Format = []) ] ); } - if ($Y != VOID) { + if ($Y != VOID_NULL) { if ($RecordImageMap) { $this->addToImageMap( "CIRCLE", @@ -5264,7 +5264,7 @@ public function drawPlotChart(array $Format = []) ] ); } - if ($X != VOID) { + if ($X != VOID_NULL) { if ($RecordImageMap) { $this->addToImageMap( "CIRCLE", @@ -5416,7 +5416,7 @@ public function drawSplineChart(array $Format = []) ] ); } - if ($RecordImageMap && $Y != VOID) { + if ($RecordImageMap && $Y != VOID_NULL) { $this->addToImageMap( "CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, @@ -5426,7 +5426,7 @@ public function drawSplineChart(array $Format = []) ); } - if ($Y == VOID && $LastY != null) { + if ($Y == VOID_NULL && $LastY != null) { $this->drawSpline( $WayPoints, [ @@ -5442,18 +5442,18 @@ public function drawSplineChart(array $Format = []) $WayPoints = []; } - if ($Y != VOID && $LastY == null && $LastGoodY != null && !$BreakVoid) { + if ($Y != VOID_NULL && $LastY == null && $LastGoodY != null && !$BreakVoid) { $this->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings); } - if ($Y != VOID) { + if ($Y != VOID_NULL) { $WayPoints[] = [$X, $Y]; } - if ($Y != VOID) { + if ($Y != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $Y = null; } @@ -5512,7 +5512,7 @@ public function drawSplineChart(array $Format = []) ] ); } - if ($RecordImageMap && $X != VOID) { + if ($RecordImageMap && $X != VOID_NULL) { $this->addToImageMap( "CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, @@ -5522,7 +5522,7 @@ public function drawSplineChart(array $Format = []) ); } - if ($X == VOID && $LastX != null) { + if ($X == VOID_NULL && $LastX != null) { $this->drawSpline( $WayPoints, [ @@ -5538,18 +5538,18 @@ public function drawSplineChart(array $Format = []) $WayPoints = []; } - if ($X != VOID && $LastX == null && $LastGoodX != null && !$BreakVoid) { + if ($X != VOID_NULL && $LastX == null && $LastGoodX != null && !$BreakVoid) { $this->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings); } - if ($X != VOID) { + if ($X != VOID_NULL) { $WayPoints[] = [$X, $Y]; } - if ($X != VOID) { + if ($X != VOID_NULL) { $LastGoodX = $X; $LastGoodY = $Y; } - if ($X == VOID) { + if ($X == VOID_NULL) { $X = null; } @@ -5678,7 +5678,7 @@ public function drawFilledSplineChart(array $Format = []) ] ); } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $Area = $this->drawSpline( $WayPoints, ["Force" => $Force, "PathOnly" => true] @@ -5813,7 +5813,7 @@ public function drawFilledSplineChart(array $Format = []) ] ); } - if ($X == VOID) { + if ($X == VOID_NULL) { $Area = $this->drawSpline( $WayPoints, ["Force" => $Force, "PathOnly" => true] @@ -6022,7 +6022,7 @@ public function drawLineChart(array $Format = []) $LastGoodY = null; $LastGoodX = null; foreach ($PosArray as $Key => $Y) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($Serie["Data"][$Key] > 0) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; @@ -6048,7 +6048,7 @@ public function drawLineChart(array $Format = []) ); } - if ($RecordImageMap && $Y != VOID) { + if ($RecordImageMap && $Y != VOID_NULL) { $this->addToImageMap( "CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, @@ -6058,7 +6058,7 @@ public function drawLineChart(array $Format = []) ); } - if ($Y != VOID && $LastX != null && $LastY != null) { + if ($Y != VOID_NULL && $LastX != null && $LastY != null) { $this->drawLine( $LastX, $LastY, @@ -6074,7 +6074,7 @@ public function drawLineChart(array $Format = []) ] ); } - if ($Y != VOID && $LastY == null && $LastGoodY != null && !$BreakVoid) { + if ($Y != VOID_NULL && $LastY == null && $LastGoodY != null && !$BreakVoid) { $this->drawLine( $LastGoodX, $LastGoodY, @@ -6085,11 +6085,11 @@ public function drawLineChart(array $Format = []) $LastGoodY = null; } - if ($Y != VOID) { + if ($Y != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $Y = null; } @@ -6115,7 +6115,7 @@ public function drawLineChart(array $Format = []) $LastGoodY = null; $LastGoodX = null; foreach ($PosArray as $Key => $X) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { $this->drawText( $X + $DisplayOffset + $Weight, $Y, @@ -6135,7 +6135,7 @@ public function drawLineChart(array $Format = []) ); } - if ($RecordImageMap && $X != VOID) { + if ($RecordImageMap && $X != VOID_NULL) { $this->addToImageMap( "CIRCLE", floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize, @@ -6145,7 +6145,7 @@ public function drawLineChart(array $Format = []) ); } - if ($X != VOID && $LastX != null && $LastY != null) { + if ($X != VOID_NULL && $LastX != null && $LastY != null) { $this->drawLine( $LastX, $LastY, @@ -6161,7 +6161,7 @@ public function drawLineChart(array $Format = []) ] ); } - if ($X != VOID && $LastX == null && $LastGoodY != null && !$BreakVoid) { + if ($X != VOID_NULL && $LastX == null && $LastGoodY != null && !$BreakVoid) { $this->drawLine( $LastGoodX, $LastGoodY, @@ -6172,11 +6172,11 @@ public function drawLineChart(array $Format = []) $LastGoodY = null; } - if ($X != VOID) { + if ($X != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($X == VOID) { + if ($X == VOID_NULL) { $X = null; } @@ -6469,7 +6469,7 @@ public function drawStepChart(array $Format = []) $LastGoodX = null; $Init = false; foreach ($PosArray as $Key => $Y) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($Y <= $LastY) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; @@ -6485,7 +6485,7 @@ public function drawStepChart(array $Format = []) ); } - if ($Y != VOID && $LastX != null && $LastY != null) { + if ($Y != VOID_NULL && $LastX != null && $LastY != null) { $this->drawLine($LastX, $LastY, $X, $LastY, $Color); $this->drawLine($X, $LastY, $X, $Y, $Color); if ($ReCenter && $X + $XStep < $this->GraphAreaX2 - $XMargin) { @@ -6524,7 +6524,7 @@ public function drawStepChart(array $Format = []) } } - if ($Y != VOID && $LastY == null && $LastGoodY != null && !$BreakVoid) { + if ($Y != VOID_NULL && $LastY == null && $LastGoodY != null && !$BreakVoid) { if ($ReCenter) { $this->drawLine($LastGoodX + $XStep, $LastGoodY, $X, $LastGoodY, $BreakSettings); if ($RecordImageMap) { @@ -6562,7 +6562,7 @@ public function drawStepChart(array $Format = []) $this->drawLine($X, $LastGoodY, $X, $Y, $BreakSettings); $LastGoodY = null; - } elseif (!$BreakVoid && $LastGoodY == null && $Y != VOID) { + } elseif (!$BreakVoid && $LastGoodY == null && $Y != VOID_NULL) { $this->drawLine($this->GraphAreaX1 + $XMargin, $Y, $X, $Y, $BreakSettings); if ($RecordImageMap) { $this->addToImageMap( @@ -6581,11 +6581,11 @@ public function drawStepChart(array $Format = []) } } - if ($Y != VOID) { + if ($Y != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $Y = null; } @@ -6637,7 +6637,7 @@ public function drawStepChart(array $Format = []) $LastGoodX = null; $Init = false; foreach ($PosArray as $Key => $X) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($X >= $LastX) { $Align = TEXT_ALIGN_MIDDLELEFT; $Offset = $DisplayOffset; @@ -6658,7 +6658,7 @@ public function drawStepChart(array $Format = []) ); } - if ($X != VOID && $LastX != null && $LastY != null) { + if ($X != VOID_NULL && $LastX != null && $LastY != null) { $this->drawLine($LastX, $LastY, $LastX, $Y, $Color); $this->drawLine($LastX, $Y, $X, $Y, $Color); @@ -6679,7 +6679,7 @@ public function drawStepChart(array $Format = []) } } - if ($X != VOID && $LastX == null && $LastGoodY != null && !$BreakVoid) { + if ($X != VOID_NULL && $LastX == null && $LastGoodY != null && !$BreakVoid) { $this->drawLine( $LastGoodX, $LastGoodY, @@ -6728,7 +6728,7 @@ public function drawStepChart(array $Format = []) $this->drawLine($LastGoodX, $Y, $X, $Y, $BreakSettings); $LastGoodY = null; - } elseif ($X != VOID && $LastGoodY == null && !$BreakVoid) { + } elseif ($X != VOID_NULL && $LastGoodY == null && !$BreakVoid) { $this->drawLine($X, $this->GraphAreaY1 + $XMargin, $X, $Y, $BreakSettings); if ($RecordImageMap) { $this->addToImageMap( @@ -6747,11 +6747,11 @@ public function drawStepChart(array $Format = []) } } - if ($X != VOID) { + if ($X != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($X == VOID) { + if ($X == VOID_NULL) { $X = null; } @@ -6868,7 +6868,7 @@ public function drawFilledStepChart(array $Format = []) $Points = []; $Init = false; foreach ($PosArray as $Key => $Y) { - if ($Y == VOID && $LastX != null && $LastY != null && count($Points)) { + if ($Y == VOID_NULL && $LastX != null && $LastY != null && count($Points)) { $Points[] = $LastX; $Points[] = $LastY; $Points[] = $X; @@ -6879,7 +6879,7 @@ public function drawFilledStepChart(array $Format = []) $Points = []; } - if ($Y != VOID && $LastX != null && $LastY != null) { + if ($Y != VOID_NULL && $LastX != null && $LastY != null) { if (count($Points)) { $Points[] = $LastX; $Points[] = $YZero; @@ -6892,11 +6892,11 @@ public function drawFilledStepChart(array $Format = []) $Points[] = $Y; } - if ($Y != VOID) { + if ($Y != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $Y = null; } @@ -6949,7 +6949,7 @@ public function drawFilledStepChart(array $Format = []) $LastGoodX = null; $Points = []; foreach ($PosArray as $Key => $X) { - if ($X == VOID && $LastX != null && $LastY != null && count($Points)) { + if ($X == VOID_NULL && $LastX != null && $LastY != null && count($Points)) { $Points[] = $LastX; $Points[] = $LastY; $Points[] = $LastX; @@ -6960,7 +6960,7 @@ public function drawFilledStepChart(array $Format = []) $Points = []; } - if ($X != VOID && $LastX != null && $LastY != null) { + if ($X != VOID_NULL && $LastX != null && $LastY != null) { if (count($Points)) { $Points[] = $YZero; $Points[] = $LastY; @@ -6973,11 +6973,11 @@ public function drawFilledStepChart(array $Format = []) $Points[] = $Y; } - if ($X != VOID) { + if ($X != VOID_NULL) { $LastGoodY = $Y; $LastGoodX = $X; } - if ($X == VOID) { + if ($X == VOID_NULL) { $X = null; } @@ -7094,7 +7094,7 @@ public function drawAreaChart(array $Format = []) $PosArray[0] = $Value; } foreach ($PosArray as $Key => $Y) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($Serie["Data"][$Key] > 0) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; @@ -7110,7 +7110,7 @@ public function drawAreaChart(array $Format = []) ); } - if ($Y == VOID && isset($Areas[$AreaID])) { + if ($Y == VOID_NULL && isset($Areas[$AreaID])) { if ($LastX == null) { $Areas[$AreaID][] = $X; } else { @@ -7123,7 +7123,7 @@ public function drawAreaChart(array $Format = []) $Areas[$AreaID][] = $this->GraphAreaY2 - 1; } $AreaID++; - } elseif ($Y != VOID) { + } elseif ($Y != VOID_NULL) { if (!isset($Areas[$AreaID])) { $Areas[$AreaID][] = $X; if ($AroundZero) { @@ -7218,7 +7218,7 @@ public function drawAreaChart(array $Format = []) $PosArray[0] = $Value; } foreach ($PosArray as $Key => $X) { - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($Serie["Data"][$Key] > 0) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; @@ -7240,7 +7240,7 @@ public function drawAreaChart(array $Format = []) ); } - if ($X == VOID && isset($Areas[$AreaID])) { + if ($X == VOID_NULL && isset($Areas[$AreaID])) { if ($AroundZero) { $Areas[$AreaID][] = $YZero; } else { @@ -7254,7 +7254,7 @@ public function drawAreaChart(array $Format = []) } $AreaID++; - } elseif ($X != VOID) { + } elseif ($X != VOID_NULL) { if (!isset($Areas[$AreaID])) { if ($AroundZero) { $Areas[$AreaID][] = $YZero; @@ -7527,7 +7527,7 @@ public function drawBarChart(array $Format = []) } } - if ($Y2 != VOID) { + if ($Y2 != VOID_NULL) { $BarHeight = $Y1 - $Y2; if ($Serie["Data"][$Key] == 0) { @@ -7702,7 +7702,7 @@ public function drawBarChart(array $Format = []) } } - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($DisplayShadow) { $this->Shadow = true; } @@ -7844,7 +7844,7 @@ public function drawBarChart(array $Format = []) } } - if ($X2 != VOID) { + if ($X2 != VOID_NULL) { $BarWidth = $X2 - $X1; if ($Serie["Data"][$Key] == 0) { $this->drawLine( @@ -8018,7 +8018,7 @@ public function drawBarChart(array $Format = []) } } - if ($DisplayValues && $Serie["Data"][$Key] != VOID) { + if ($DisplayValues && $Serie["Data"][$Key] != VOID_NULL) { if ($DisplayShadow) { $this->Shadow = true; } @@ -8214,7 +8214,7 @@ public function drawStackedBarChart(array $Format = []) $PosArray[0] = $Value; } foreach ($PosArray as $Key => $Height) { - if ($Height != VOID && $Serie["Data"][$Key] != 0) { + if ($Height != VOID_NULL && $Serie["Data"][$Key] != 0) { if ($Serie["Data"][$Key] > 0) { $Pos = "+"; } else { @@ -8454,7 +8454,7 @@ public function drawStackedBarChart(array $Format = []) $PosArray[0] = $Value; } foreach ($PosArray as $Key => $Width) { - if ($Width != VOID && $Serie["Data"][$Key] != 0) { + if ($Width != VOID_NULL && $Serie["Data"][$Key] != 0) { if ($Serie["Data"][$Key] > 0) { $Pos = "+"; } else { @@ -8682,9 +8682,9 @@ public function drawStackedAreaChart(array $Format = []) { $DrawLine = isset($Format["DrawLine"]) ? $Format["DrawLine"] : false; $LineSurrounding = isset($Format["LineSurrounding"]) ? $Format["LineSurrounding"] : null; - $LineR = isset($Format["LineR"]) ? $Format["LineR"] : VOID; - $LineG = isset($Format["LineG"]) ? $Format["LineG"] : VOID; - $LineB = isset($Format["LineB"]) ? $Format["LineB"] : VOID; + $LineR = isset($Format["LineR"]) ? $Format["LineR"] : VOID_NULL; + $LineG = isset($Format["LineG"]) ? $Format["LineG"] : VOID_NULL; + $LineB = isset($Format["LineB"]) ? $Format["LineB"] : VOID_NULL; $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100; $DrawPlot = isset($Format["DrawPlot"]) ? $Format["DrawPlot"] : false; $PlotRadius = isset($Format["PlotRadius"]) ? $Format["PlotRadius"] : 2; @@ -8712,7 +8712,7 @@ public function drawStackedAreaChart(array $Format = []) $SerieOrder[] = $SerieName; foreach ($Serie["Data"] as $Key => $Value) { - if ($Value == VOID) { + if ($Value == VOID_NULL) { $Value = 0; } if ($Value >= 0) { @@ -8756,7 +8756,7 @@ public function drawStackedAreaChart(array $Format = []) "B" => $B + $LineSurrounding, "Alpha" => $Alpha ]; - } elseif ($LineR != VOID) { + } elseif ($LineR != VOID_NULL) { $LineColor = [ "R" => $LineR, "G" => $LineG, @@ -8818,7 +8818,7 @@ public function drawStackedAreaChart(array $Format = []) $Plots[] = $X; $Plots[] = $YZero; foreach ($PosArray as $Key => $Height) { - if ($Height != VOID) { + if ($Height != VOID_NULL) { $Plots[] = $X; $Plots[] = $YZero - $Height; } @@ -8880,7 +8880,7 @@ public function drawStackedAreaChart(array $Format = []) $Plots[] = $YZero; $Plots[] = $Y; foreach ($PosArray as $Key => $Height) { - if ($Height != VOID) { + if ($Height != VOID_NULL) { $Plots[] = $YZero + $Height; $Plots[] = $Y; } @@ -9107,7 +9107,7 @@ public function drawDerivative(array $Format = []) $MinSlope = 0; $MaxSlope = 1; foreach ($PosArray as $Key => $Y) { - if ($Y != VOID && $LastX != null) { + if ($Y != VOID_NULL && $LastX != null) { $Slope = ($LastY - $Y); if ($Slope > $MaxSlope) { $MaxSlope = $Slope; @@ -9116,7 +9116,7 @@ public function drawDerivative(array $Format = []) } } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $LastX = null; $LastY = null; } else { @@ -9129,7 +9129,7 @@ public function drawDerivative(array $Format = []) $LastY = null; $LastColor = null; foreach ($PosArray as $Key => $Y) { - if ($Y != VOID && $LastY != null) { + if ($Y != VOID_NULL && $LastY != null) { $Slope = ($LastY - $Y); if ($Slope >= 0) { @@ -9187,7 +9187,7 @@ public function drawDerivative(array $Format = []) $LastColor = $Color; } - if ($Y == VOID) { + if ($Y == VOID_NULL) { $LastY = null; } else { $LastX = $X; @@ -9311,7 +9311,7 @@ public function drawDerivative(array $Format = []) $MinSlope = 0; $MaxSlope = 1; foreach ($PosArray as $Key => $X) { - if ($X != VOID && $LastX != null) { + if ($X != VOID_NULL && $LastX != null) { $Slope = ($X - $LastX); if ($Slope > $MaxSlope) { $MaxSlope = $Slope; @@ -9321,7 +9321,7 @@ public function drawDerivative(array $Format = []) } } - if ($X == VOID) { + if ($X == VOID_NULL) { $LastX = null; } else { $LastX = $X; @@ -9332,7 +9332,7 @@ public function drawDerivative(array $Format = []) $LastY = null; $LastColor = null; foreach ($PosArray as $Key => $X) { - if ($X != VOID && $LastX != null) { + if ($X != VOID_NULL && $LastX != null) { $Slope = ($X - $LastX); if ($Slope >= 0) { @@ -9391,7 +9391,7 @@ public function drawDerivative(array $Format = []) $LastColor = $Color; } - if ($X == VOID) { + if ($X == VOID_NULL) { $LastX = null; } else { $LastX = $X; @@ -9415,17 +9415,17 @@ public function drawDerivative(array $Format = []) public function drawBestFit(array $Format = []) { $OverrideTicks = isset($Format["Ticks"]) ? $Format["Ticks"] : null; - $OverrideR = isset($Format["R"]) ? $Format["R"] : VOID; - $OverrideG = isset($Format["G"]) ? $Format["G"] : VOID; - $OverrideB = isset($Format["B"]) ? $Format["B"] : VOID; - $OverrideAlpha = isset($Format["Alpha"]) ? $Format["Alpha"] : VOID; + $OverrideR = isset($Format["R"]) ? $Format["R"] : VOID_NULL; + $OverrideG = isset($Format["G"]) ? $Format["G"] : VOID_NULL; + $OverrideB = isset($Format["B"]) ? $Format["B"] : VOID_NULL; + $OverrideAlpha = isset($Format["Alpha"]) ? $Format["Alpha"] : VOID_NULL; $Data = $this->DataSet->getData(); list($XMargin, $XDivs) = $this->scaleGetXSettings(); foreach ($Data["Series"] as $SerieName => $Serie) { if ($Serie["isDrawable"] == true && $SerieName != $Data["Abscissa"]) { - if ($OverrideR != VOID && $OverrideG != VOID && $OverrideB != VOID) { + if ($OverrideR != VOID_NULL && $OverrideG != VOID_NULL && $OverrideB != VOID_NULL) { $R = $OverrideR; $G = $OverrideG; $B = $OverrideB; @@ -9439,7 +9439,7 @@ public function drawBestFit(array $Format = []) } else { $Ticks = $OverrideTicks; } - if ($OverrideAlpha == VOID) { + if ($OverrideAlpha == VOID_NULL) { $Alpha = $Serie["Color"]["Alpha"]; } else { $Alpha = $OverrideAlpha; @@ -9470,7 +9470,7 @@ public function drawBestFit(array $Format = []) $Sy = 0; $Sxx = 0; foreach ($PosArray as $Key => $Y) { - if ($Y != VOID) { + if ($Y != VOID_NULL) { $Sxy = $Sxy + $X * $Y; $Sx = $Sx + $X; $Sy = $Sy + $Y; @@ -9479,7 +9479,7 @@ public function drawBestFit(array $Format = []) $X = $X + $XStep; } - $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray); + $n = count($this->DataSet->stripVOID_NULL($PosArray)); //$n = count($PosArray); $M = (($n * $Sxy) - ($Sx * $Sy)) / (($n * $Sxx) - ($Sx * $Sx)); $B = (($Sy) - ($M * $Sx)) / ($n); @@ -9524,7 +9524,7 @@ public function drawBestFit(array $Format = []) $Sy = 0; $Sxx = 0; foreach ($PosArray as $Key => $X) { - if ($X != VOID) { + if ($X != VOID_NULL) { $Sxy = $Sxy + $X * $Y; $Sx = $Sx + $Y; $Sy = $Sy + $X; @@ -9533,7 +9533,7 @@ public function drawBestFit(array $Format = []) $Y = $Y + $YStep; } - $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray); + $n = count($this->DataSet->stripVOID_NULL($PosArray)); //$n = count($PosArray); $M = (($n * $Sxy) - ($Sx * $Sy)) / (($n * $Sxx) - ($Sx * $Sx)); $B = (($Sy) - ($M * $Sx)) / ($n); @@ -10187,7 +10187,7 @@ public function drawPolygonChart(array $Points, array $Format = []) /* Simplify straight lines */ $Result = []; $inHorizon = false; - $LastX = VOID; + $LastX = VOID_NULL; foreach ($Segments as $Key => $Pos) { if ($Pos["Y1"] != $Pos["Y2"]) { if ($inHorizon) { diff --git a/src/Image.php b/src/Image.php index 59773d1..c154b7f 100644 --- a/src/Image.php +++ b/src/Image.php @@ -16,7 +16,7 @@ use const TEXT_ALIGN_TOPLEFT; use const TEXT_ALIGN_TOPMIDDLE; use const TEXT_ALIGN_TOPRIGHT; -use const VOID; +use const VOID_NULL; class Image extends Draw { @@ -505,12 +505,12 @@ public function addToImageMap( } /** - * Remove VOID values from an imagemap custom values array + * Remove VOID_NULL values from an imagemap custom values array * @param string $SerieName * @param array $Values * @return list|int */ - public function removeVOIDFromArray($SerieName, array $Values) + public function removeVOID_NULLFromArray($SerieName, array $Values) { if (!isset($this->DataSet->Data["Series"][$SerieName])) { return -1; @@ -518,7 +518,7 @@ public function removeVOIDFromArray($SerieName, array $Values) $Result = []; foreach ($this->DataSet->Data["Series"][$SerieName]["Data"] as $Key => $Value) { - if ($Value != VOID && isset($Values[$Key])) { + if ($Value != VOID_NULL && isset($Values[$Key])) { $Result[] = $Values[$Key]; } } @@ -539,7 +539,7 @@ public function replaceImageMapTitle($OldTitle, $NewTitle) } if (is_array($NewTitle)) { - $NewTitle = $this->removeVOIDFromArray($OldTitle, $NewTitle); + $NewTitle = $this->removeVOID_NULLFromArray($OldTitle, $NewTitle); } if ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION) { @@ -632,7 +632,7 @@ public function replaceImageMapValues($Title, array $Values) return -1; } - $Values = $this->removeVOIDFromArray($Title, $Values); + $Values = $this->removeVOID_NULLFromArray($Title, $Values); $ID = 0; if ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION) { if (!isset($_SESSION)) { diff --git a/tests/unit/BarTest.php b/tests/unit/BarTest.php index 289e268..465e6e2 100644 --- a/tests/unit/BarTest.php +++ b/tests/unit/BarTest.php @@ -15,7 +15,7 @@ use const LEGEND_NOBORDER; use const SCALE_POS_TOPBOTTOM; use const TEXT_ALIGN_BOTTOMMIDDLE; -use const VOID; +use const VOID_NULL; final class BarTest extends Unit { @@ -24,7 +24,7 @@ final class BarTest extends Unit public function testChartRender(): void { $data = new Data(); - $data->addPoints([-4, VOID, VOID, 12, 8, 3], 'Probe 1'); + $data->addPoints([-4, VOID_NULL, VOID_NULL, 12, 8, 3], 'Probe 1'); $data->addPoints([3, 12, 15, 8, 5, -5], 'Probe 2'); $data->addPoints([2, 0, 5, 18, 19, 22], 'Probe 3'); $data->setSerieTicks('Probe 2', 4); diff --git a/tests/unit/FilledStepTest.php b/tests/unit/FilledStepTest.php index 611f8e1..da1a0e4 100644 --- a/tests/unit/FilledStepTest.php +++ b/tests/unit/FilledStepTest.php @@ -15,7 +15,7 @@ use const LEGEND_NOBORDER; use const SCALE_POS_TOPBOTTOM; use const TEXT_ALIGN_BOTTOMMIDDLE; -use const VOID; +use const VOID_NULL; final class FilledStepTest extends Unit { @@ -24,7 +24,7 @@ final class FilledStepTest extends Unit public function testChartRender(): void { $data = new Data(); - $data->addPoints([-4, 2, VOID, 12, 8, 3], 'Probe 1'); + $data->addPoints([-4, 2, VOID_NULL, 12, 8, 3], 'Probe 1'); $data->addPoints([3, 12, 15, 8, 5, -5], 'Probe 2'); $data->addPoints([2, 7, 5, 18, 19, 22], 'Probe 3'); $data->setSerieTicks('Probe 2', 4); diff --git a/tests/unit/LineTest.php b/tests/unit/LineTest.php index 5156654..6cd74b8 100644 --- a/tests/unit/LineTest.php +++ b/tests/unit/LineTest.php @@ -13,7 +13,7 @@ use const LEGEND_HORIZONTAL; use const LEGEND_NOBORDER; use const SCALE_POS_TOPBOTTOM; -use const VOID; +use const VOID_NULL; final class LineTest extends Unit { @@ -22,7 +22,7 @@ final class LineTest extends Unit public function testChartRender(): void { $data = new Data(); - $data->addPoints([-4, VOID, VOID, 12, 8, 3], 'Probe 1'); + $data->addPoints([-4, VOID_NULL, VOID_NULL, 12, 8, 3], 'Probe 1'); $data->addPoints([3, 12, 15, 8, 5, -5], 'Probe 2'); $data->addPoints([2, 7, 5, 18, 19, 22], 'Probe 3'); $data->setSerieTicks('Probe 2', 4); diff --git a/tests/unit/StepTest.php b/tests/unit/StepTest.php index 814608d..f94ae57 100644 --- a/tests/unit/StepTest.php +++ b/tests/unit/StepTest.php @@ -15,7 +15,7 @@ use const LEGEND_NOBORDER; use const SCALE_POS_TOPBOTTOM; use const TEXT_ALIGN_BOTTOMMIDDLE; -use const VOID; +use const VOID_NULL; final class StepTest extends Unit { @@ -24,7 +24,7 @@ final class StepTest extends Unit public function testChartRender(): void { $data = new Data(); - $data->addPoints([-4, VOID, VOID, 12, 8, 3], 'Probe 1'); + $data->addPoints([-4, VOID_NULL, VOID_NULL, 12, 8, 3], 'Probe 1'); $data->addPoints([3, 12, 15, 8, 5, -5], 'Probe 2'); $data->addPoints([2, 7, 5, 18, 19, 22], 'Probe 3'); $data->setSerieTicks('Probe 2', 4);