diff --git a/Cluster.php b/Cluster.php index c627140..7be0cbd 100644 --- a/Cluster.php +++ b/Cluster.php @@ -15,7 +15,7 @@ class Cluster { private $clusterId; public $clusterSize; public $peerClusterRatioNorm; - private $bgColor = "white"; + public $bgColor = "white"; private $range = 0.20; public function __construct($clusterArray = array(), $clusterId) { diff --git a/View.php b/View.php index 0c3bdce..f095382 100644 --- a/View.php +++ b/View.php @@ -52,7 +52,7 @@ class View { } private function calcPeerClusterRatio() { - $this->peerClusterRatioRef = round($this->peerCount / $this->clusterCount,5); + $this->peerClusterRatioRef = round($this->peerCount / $this->clusterCount, 5); $variance = 0.0; $medianArray = array(); foreach ($this->clusterList as $value) { @@ -62,13 +62,13 @@ class View { } $variance /= $this->peerCount; - $this->peerClusterRatioNormVar = round($variance,5); - $this->peerClusterRatioNormStDev = round(sqrt($variance),5); + $this->peerClusterRatioNormVar = round($variance, 5); + $this->peerClusterRatioNormStDev = round(sqrt($variance), 5); asort($medianArray); $medianArraySize = count($medianArray); - $medianMidIndex = round(($medianArraySize - 1) / 2,0,PHP_ROUND_HALF_DOWN); + $medianMidIndex = round(($medianArraySize - 1) / 2, 0, PHP_ROUND_HALF_DOWN); if ($medianArraySize % 2 == 0) { $this->peerClusterRatioNormMed = ($medianArray[$medianMidIndex] + $medianArray[$medianMidIndex + 1]) / 2; } else { @@ -94,10 +94,57 @@ class View { $table .= "ClusterListe: "; $table .= $this->clusterListToHTML(); $table .= ""; + $table .= ""; + $table .= $this->toSVG(); + $table .= ""; $table .= ""; return $table; } -} + public function toSVG() { + $svg = ''; + $svg .= $this->createClusterSVG(); + //$svg .= ''; + //$svg .= ''; + //$svg .= ''; + //$svg .= ''; + $svg .= ''; + return $svg; + } + public function createClusterSVG() { + $midX = 160; + $midY = 160; + $svg = ""; + foreach ($this->clusterList as $value) { + $clSize = $value->clusterSize; + $r = $clSize * 15; + $strokebg = "gray"; + if (strcmp($value->bgColor,"white") != 0) { + $strokebg = $value->bgColor; + } + $svg .= ''; + $svg .= $this->fillPoints($midX, $midY, $clSize, $r); + $midX += 2.5 * $r; + } + + return $svg; + } + + public function fillPoints($midX, $midY, $count, $r) { + $startX = $midX - $r; + $endX = $midX + $r; + $startY = $midY - $r; + $endY = $midY + $r; + $midXT = $startX + 15; + $midYT = $midY; + $svg = ""; + for ($i = 0; $i < $count; $i++) { + $svg .= ''; + $midXT += 30; + } + return $svg; + } + +} ?> diff --git a/index.php b/index.php index 7bb2142..d7cedf7 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,6 @@ + + + + + + + + + + + \ No newline at end of file