Skip to content

Commit

Permalink
Some minor changes for php 7
Browse files Browse the repository at this point in the history
  • Loading branch information
milkyway-git committed May 29, 2019
1 parent 46fd01c commit f330e9b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
58 changes: 29 additions & 29 deletions src/pChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function loadColorPalette($FileName, $Delimiter = ",")
$buffer = fgets($handle, 4096);
$buffer = str_replace(chr(10), "", $buffer);
$buffer = str_replace(chr(13), "", $buffer);
$Values = split($Delimiter, $buffer);
$Values = explode($Delimiter, $buffer);
if (count($Values) == 3) {
$this->Palette[$ColorID]["R"] = $Values[0];
$this->Palette[$ColorID]["G"] = $Values[1];
Expand Down Expand Up @@ -1828,7 +1828,7 @@ function drawArea($Data, $Serie1, $Serie2, $R, $G, $B, $Alpha = 50)
$YPos2 = $LayerHeight - (($Value2 - $this->VMin) * $this->DivisionRatio);

if ($LastXPos != -1) {
$Points = "";
$Points = array();
$Points[] = $LastXPos;
$Points[] = $LastYPos1;
$Points[] = $LastXPos;
Expand Down Expand Up @@ -2009,10 +2009,10 @@ function drawCubicCurve($Data, $DataDescription, $Accuracy = .1, $SerieName = ""
$GraphID = 0;
foreach ($DataDescription["Values"] as $Key2 => $ColName) {
if ($SerieName == "" || $SerieName == $ColName) {
$XIn = "";
$Yin = "";
$Yt = "";
$U = "";
$XIn = array();
$Yin = array();
$Yt = array();
$U = array();
$XIn[0] = 0;
$YIn[0] = 0;

Expand All @@ -2026,7 +2026,7 @@ function drawCubicCurve($Data, $DataDescription, $Accuracy = .1, $SerieName = ""

$Index = 1;
$XLast = -1;
$Missing = "";
$Missing = array();
foreach ($Data as $Key => $Values) {
if (isset($Data[$Key][$ColName])) {
$Value = $Data[$Key][$ColName];
Expand Down Expand Up @@ -2125,10 +2125,10 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha =

$GraphID = 0;
foreach ($DataDescription["Values"] as $Key2 => $ColName) {
$XIn = "";
$Yin = "";
$Yt = "";
$U = "";
$XIn = array();
$Yin = array();
$Yt = array();
$U = array();
$XIn[0] = 0;
$YIn[0] = 0;

Expand All @@ -2142,7 +2142,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha =

$Index = 1;
$XLast = -1;
$Missing = "";
$Missing = array();
foreach ($Data as $Key => $Values) {
$Value = $Data[$Key][$ColName];
$XIn[$Index] = $Index;
Expand Down Expand Up @@ -2172,7 +2172,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha =
for ($k = $Index - 1; $k >= 1; $k--)
$Yt[$k] = $Yt[$k] * $Yt[$k + 1] + $U[$k];

$Points = "";
$Points = array();
$Points[] = $this->GAreaXOffset;
$Points[] = $LayerHeight;

Expand Down Expand Up @@ -2205,7 +2205,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha =
$YPos = $LayerHeight - (($Value - $this->VMin) * $this->DivisionRatio);

if ($YLast != NULL && $AroundZero && !isset($Missing[floor($X)]) && !isset($Missing[floor($X + 1)])) {
$aPoints = "";
$aPoints = array();
$aPoints[] = $XLast;
$aPoints[] = $YLast;
$aPoints[] = $XPos;
Expand Down Expand Up @@ -2241,7 +2241,7 @@ function drawFilledCubicCurve($Data, $DataDescription, $Accuracy = .1, $Alpha =
$YPos = $LayerHeight - (($YIn[$Index] - $this->VMin) * $this->DivisionRatio);

if ($YLast != NULL && $AroundZero) {
$aPoints = "";
$aPoints = array();
$aPoints[] = $XLast;
$aPoints[] = $YLast;
$aPoints[] = $LayerWidth - $this->GAreaXOffset;
Expand Down Expand Up @@ -2310,7 +2310,7 @@ function drawFilledLineGraph($Data, $DataDescription, $Alpha = 100, $AroundZero
$ID++;
}

$aPoints = "";
$aPoints = array();
$aPoints[] = $this->GAreaXOffset;
$aPoints[] = $LayerHeight;

Expand Down Expand Up @@ -2358,7 +2358,7 @@ function drawFilledLineGraph($Data, $DataDescription, $Alpha = 100, $AroundZero
}

if ($YLast <> $Empty && $AroundZero) {
$Points = "";
$Points = array();
$Points[] = $XLast;
$Points[] = $YLast;
$Points[] = $XPos;
Expand Down Expand Up @@ -2559,7 +2559,7 @@ function drawStackedBarGraph($Data, $DataDescription, $Alpha = 50, $Contiguous =
}

$SerieID = 0;
$LastValue = "";
$LastValue = array();
foreach ($DataDescription["Values"] as $ColName) {
$ID = 0;
foreach ($DataDescription["Description"] as $keyI => $ValueI) {
Expand Down Expand Up @@ -2723,7 +2723,7 @@ function drawRadarAxis($Data, $DataDescription, $Mosaic = TRUE, $BorderOffset =
$Y2 = sin($Angle * 3.1418 / 180) * ($TRadius + $RadiusScale) + $YCenter;

if ($t % 2 == 1 && $LastX1 != -1) {
$Plots = "";
$Plots = array();
$Plots[] = $X1;
$Plots[] = $Y1;
$Plots[] = $X2;
Expand Down Expand Up @@ -2939,7 +2939,7 @@ function drawFilledRadar($Data, $DataDescription, $Alpha = 50, $BorderOffset = 1

$Angle = -90;
$XLast = -1;
$Plots = "";
$Plots = array();
foreach ($Data as $Key => $Values) {
if (isset($Data[$Key][$ColName])) {
$Value = $Data[$Key][$ColName];
Expand Down Expand Up @@ -3028,7 +3028,7 @@ function drawBasicPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100,

/* Calculate all polygons */
$Angle = 0;
$TopPlots = "";
$TopPlots = array();
foreach ($iValues as $Key => $Value) {
$TopPlots[$Key][] = $XPos;
$TopPlots[$Key][] = $YPos;
Expand Down Expand Up @@ -3158,7 +3158,7 @@ function drawFlatPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100,

/* Calculate all polygons */
$Angle = 0;
$TopPlots = "";
$TopPlots = array();
foreach ($iValues as $Key => $Value) {
$XOffset = cos(($Angle + ($Value / 2 * $SpliceRatio)) * 3.1418 / 180) * $SpliceDistance;
$YOffset = sin(($Angle + ($Value / 2 * $SpliceRatio)) * 3.1418 / 180) * $SpliceDistance;
Expand Down Expand Up @@ -3317,10 +3317,10 @@ function drawPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, $Dra
/* Calculate all polygons */
$Angle = 0;
$CDev = 5;
$TopPlots = "";
$BotPlots = "";
$aTopPlots = "";
$aBotPlots = "";
$TopPlots = array();
$BotPlots = array();
$aTopPlots = array();
$aBotPlots = array();
foreach ($iValues as $Key => $Value) {
$XCenterPos = cos(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * 3.1418 / 180) * $SpliceDistance + $XPos;
$YCenterPos = sin(($Angle - $CDev + ($Value * $SpliceRatio + $SpliceDistanceRatio) / 2) * 3.1418 / 180) * $SpliceDistance + $YPos;
Expand Down Expand Up @@ -3418,7 +3418,7 @@ function drawPieGraph($Data, $DataDescription, $XPos, $YPos, $Radius = 100, $Dra
for ($i = $SpliceHeight - 1; $i >= 1; $i--) {
foreach ($iValues as $Key => $Value) {
$C_GraphLo = $this->AllocateColor($this->Picture, $this->Palette[$Key]["R"], $this->Palette[$Key]["G"], $this->Palette[$Key]["B"], -10);
$Plots = "";
$Plots = array();
$Plot = 0;
foreach ($TopPlots[$Key] as $Key2 => $Value2) {
$Plot++;
Expand Down Expand Up @@ -4468,7 +4468,7 @@ function validateData($FunctionName, &$Data)
*/
function printErrors($Mode = "CLI")
{
if (count($this->Errors) == 0)
if (!is_array($this->Errors))
return 0;

if ($Mode == "CLI") {
Expand Down Expand Up @@ -4542,7 +4542,7 @@ function getImageMap($MapName, $Flush = TRUE)
{
/* Strip HTML query strings */
$Values = $this->tmpFolder . $MapName;
$Value = split("\?", $Values);
$Value = explode('?', $Values);
$FileName = $Value[0];

if (file_exists($FileName)) {
Expand Down
8 changes: 4 additions & 4 deletions src/pData.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class pData

function __construct()
{
$this->Data = "";
$this->DataDescription = "";
$this->Data = array();
$this->DataDescription = array();
$this->DataDescription["Position"] = "Name";
$this->DataDescription["Format"]["X"] = "number";
$this->DataDescription["Format"]["Y"] = "number";
Expand All @@ -74,7 +74,7 @@ function ImportFromCSV($FileName, $Delimiter = ",", $DataColumns = -1, $HasHeade
$buffer = fgets($handle, 4096);
$buffer = str_replace(chr(10), "", $buffer);
$buffer = str_replace(chr(13), "", $buffer);
$Values = split($Delimiter, $buffer);
$Values = explode($Delimiter, $buffer);

if ($buffer != "") {
if ($HasHeader == TRUE && $HeaderParsed == FALSE) {
Expand Down Expand Up @@ -128,7 +128,7 @@ function AddPoint($Value, $Serie = "Serie1", $Description = "")
}
}

if (count($Value) == 1) {
if (!is_array($Value)) {
$this->Data[$ID][$Serie] = $Value;
if ($Description != "")
$this->Data[$ID]["Name"] = $Description;
Expand Down

0 comments on commit f330e9b

Please sign in to comment.