function pChart::drawRadar in Visitors 7.0
Same name and namespace in other branches
- 8 pchart/pChart.inc \pChart::drawRadar()
File
- pchart/
pChart.inc, line 1613
Class
Code
function drawRadar(&$Data, &$DataDescription, $BorderOffset = 10, $MaxValue = -1) {
/* Validate the Data and DataDescription array */
$this
->validateDataDescription("drawRadar", $DataDescription);
$this
->validateData("drawRadar", $Data);
$Points = count($Data);
$Radius = ($this->GArea_Y2 - $this->GArea_Y1) / 2 - $BorderOffset;
$XCenter = ($this->GArea_X2 - $this->GArea_X1) / 2 + $this->GArea_X1;
$YCenter = ($this->GArea_Y2 - $this->GArea_Y1) / 2 + $this->GArea_Y1;
/* Search for the max value */
if ($MaxValue == -1) {
foreach ($DataDescription["Values"] as $Key2 => $ColName) {
foreach ($Data as $Key => $Values) {
if (isset($Data[$Key][$ColName])) {
if ($Data[$Key][$ColName] > $MaxValue) {
$MaxValue = $Data[$Key][$ColName];
}
}
}
}
}
$GraphID = 0;
foreach ($DataDescription["Values"] as $Key2 => $ColName) {
$ID = 0;
foreach ($DataDescription["Description"] as $keyI => $ValueI) {
if ($keyI == $ColName) {
$ColorID = $ID;
}
$ID++;
}
$Angle = -90;
$XLast = -1;
foreach ($Data as $Key => $Values) {
if (isset($Data[$Key][$ColName])) {
$Value = $Data[$Key][$ColName];
$Strength = $Radius / $MaxValue * $Value;
$XPos = cos($Angle * 3.1418 / 180) * $Strength + $XCenter;
$YPos = sin($Angle * 3.1418 / 180) * $Strength + $YCenter;
if ($XLast != -1) {
$this
->drawLine($XLast, $YLast, $XPos, $YPos, $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"]);
}
if ($XLast == -1) {
$FirstX = $XPos;
$FirstY = $YPos;
}
$Angle = $Angle + 360 / $Points;
$XLast = $XPos;
$YLast = $YPos;
}
}
$this
->drawLine($XPos, $YPos, $FirstX, $FirstY, $this->Palette[$ColorID]["R"], $this->Palette[$ColorID]["G"], $this->Palette[$ColorID]["B"]);
$GraphID++;
}
}