function pChart::drawFilledLineGraph in Visitors 8
Same name and namespace in other branches
- 7.0 pchart/pChart.inc \pChart::drawFilledLineGraph()
File
- pchart/
pChart.inc, line 1180
Class
Code
function drawFilledLineGraph(&$Data, &$DataDescription, $Alpha = 100, $AroundZero = FALSE) {
$Empty = -2147483647;
/* Validate the Data and DataDescription array */
$this
->validateDataDescription("drawFilledLineGraph", $DataDescription);
$this
->validateData("drawFilledLineGraph", $Data);
$LayerWidth = $this->GArea_X2 - $this->GArea_X1;
$LayerHeight = $this->GArea_Y2 - $this->GArea_Y1;
$GraphID = 0;
foreach ($DataDescription["Values"] as $Key2 => $ColName) {
$ID = 0;
foreach ($DataDescription["Description"] as $keyI => $ValueI) {
if ($keyI == $ColName) {
$ColorID = $ID;
}
$ID++;
}
$aPoints = "";
$aPoints[] = $this->GAreaXOffset;
$aPoints[] = $LayerHeight;
$this->Layers[0] = imagecreatetruecolor($LayerWidth, $LayerHeight);
$C_White = imagecolorallocate($this->Layers[0], 255, 255, 255);
imagefilledrectangle($this->Layers[0], 0, 0, $LayerWidth, $LayerHeight, $C_White);
imagecolortransparent($this->Layers[0], $C_White);
$XPos = $this->GAreaXOffset;
$XLast = -1;
$PointsCount = 2;
$YZero = $LayerHeight - (0 - $this->VMin) * $this->DivisionRatio;
if ($YZero > $LayerHeight) {
$YZero = $LayerHeight;
}
$YLast = $Empty;
foreach ($Data as $Key => $Values) {
$Value = $Data[$Key][$ColName];
$YPos = $LayerHeight - ($Value - $this->VMin) * $this->DivisionRatio;
if (!is_numeric($Value)) {
$PointsCount++;
$aPoints[] = $XLast;
$aPoints[] = $LayerHeight;
$YLast = $Empty;
}
else {
$PointsCount++;
if ($YLast != $Empty) {
$aPoints[] = $XPos;
$aPoints[] = $YPos;
}
else {
$PointsCount++;
$aPoints[] = $XPos;
$aPoints[] = $LayerHeight;
$aPoints[] = $XPos;
$aPoints[] = $YPos;
}
if ($YLast != $Empty && $AroundZero) {
$Points = "";
$Points[] = $XLast;
$Points[] = $YLast;
$Points[] = $XPos;
$Points[] = $YPos;
$Points[] = $XPos;
$Points[] = $YZero;
$Points[] = $XLast;
$Points[] = $YZero;
$C_Graph = imagecolorallocate($this->Layers[0], $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"]);
imagefilledpolygon($this->Layers[0], $Points, 4, $C_Graph);
}
$YLast = $YPos;
}
$XLast = $XPos;
$XPos = $XPos + $this->DivisionWidth;
}
$aPoints[] = $LayerWidth - $this->GAreaXOffset;
$aPoints[] = $LayerHeight;
if ($AroundZero == FALSE) {
$C_Graph = imagecolorallocate($this->Layers[0], $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"]);
imagefilledpolygon($this->Layers[0], $aPoints, $PointsCount, $C_Graph);
}
imagecopymerge($this->Picture, $this->Layers[0], $this->GArea_X1, $this->GArea_Y1, 0, 0, $LayerWidth, $LayerHeight, $Alpha);
imagedestroy($this->Layers[0]);
$GraphID++;
$this
->drawLineGraph($Data, $DataDescription, $ColName);
}
}