update20130718
This commit is contained in:
@@ -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) {
|
||||
|
||||
57
View.php
57
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 .= "<tr><td>ClusterListe:</td> <td colspan=\"7\">";
|
||||
$table .= $this->clusterListToHTML();
|
||||
$table .= "</td></tr>";
|
||||
$table .= "<tr><td colspan=\"8\">";
|
||||
$table .= $this->toSVG();
|
||||
$table .= "</td></tr>";
|
||||
$table .= "</table>";
|
||||
return $table;
|
||||
}
|
||||
|
||||
}
|
||||
public function toSVG() {
|
||||
$svg = '<svg xmlns = "http://www.w3.org/2000/svg" xmlns:xlink = "http://www.w3.org/1999/xlink" xmlns:ev = "http://www.w3.org/2001/xml-events" version = "1.1" baseProfile = "full" width="100%" height="350">';
|
||||
$svg .= $this->createClusterSVG();
|
||||
//$svg .= '<circle cx = "110" cy = "110" r = "10" fill = "full" />';
|
||||
//$svg .= '<circle cx = "410" cy = "110" r = "100" stroke = "#4e9a06" stroke-width = "4" fill = "none" />';
|
||||
//$svg .= '<circle cx = "410" cy = "110" r = "10" fill = "full" />';
|
||||
//$svg .= '<line x1 = "110" y1 = "110" x2 = "410" y2 = "110" style = "stroke:rgb(255,0,0);stroke-width:2"/>';
|
||||
$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 .= '<circle cx = "' . $midX . '" cy = "' . $midY . '" r = "' . $r . '" stroke = "'.$strokebg.'" stroke-width = "4" fill = "none" />';
|
||||
$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 .= '<circle cx = "' . $midXT . '" cy = "' . $midYT . '" r = "10" fill = "full" />';
|
||||
$midXT += 30;
|
||||
}
|
||||
return $svg;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once 'View.php';
|
||||
|
||||
$sourceString = file_get_contents("mr.json");
|
||||
//echo $sourceString;
|
||||
$source = json_decode($sourceString, true);
|
||||
|
||||
14
test.svg
Normal file
14
test.svg
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"
|
||||
version="1.1" baseProfile="full" >
|
||||
|
||||
<circle cx="110" cy="110" r="100" stroke="#4e9a06" stroke-width="4" fill="none" />
|
||||
<circle cx="110" cy="110" r="10" fill="full" />
|
||||
|
||||
<circle cx="410" cy="110" r="100" stroke="#4e9a06" stroke-width="4" fill="none" />
|
||||
<circle cx="410" cy="110" r="10" fill="full" />
|
||||
<line x1="110" y1="110" x2="410" y2="110" style="stroke:rgb(255,0,0);stroke-width:2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 689 B |
Reference in New Issue
Block a user