/** * Construct a circle * * @param integer $cx the center x * @param integer $cy the center y * @param integer $radius the radius of circle * @param string $id the id of element * @param SVGStyle $style style of element * * @return SVGCircle */ public static function getInstance($cx, $cy, $radius, $id = null, $style = null) { $circle = new SVGCircle('<circle></circle>'); $circle->setCx($cx); $circle->setCy($cy); $circle->setRadius($radius); $circle->setId($id); $circle->setStyle($style); return $circle; }
public function onCreate() { if (!$this->getMaxY()) { $this->findMaxY(); } if (!$this->getMaxX()) { $this->findMaxX(); } $this->setWidth($this->getMaxX() + 100 . 'px'); $this->setHeight($this->getMaxY() + 100 . 'px'); $this->setDefaultViewBox(); $clipPath = SVGClipPath::getInstance('clipPath'); $clipRect = SVGRect::getInstance(0, 0, null, $this->getWidth(), $this->getHeight()); $clipPath->addShape($clipRect); $this->addDefs($clipPath); $backGroup = SVGGroup::getInstance('backGroup'); $line1 = SVGLine::getInstance($this->startX, $this->startY, $this->startX, $this->maxY + $this->startY, null, new SVGStyle(array('stroke' => 'black', 'stroke-width' => 1))); $line2 = SVGLine::getInstance($this->startX, $this->maxY + $this->startY, $this->maxX + $this->startX, $this->maxY + $this->startY, null, new SVGStyle(array('stroke' => 'black', 'stroke-width' => 1))); $backGroup->addShape($line1); $backGroup->addShape($line2); #vertical counter for ($i = 0; $i <= $this->maxY; $i += 25) { $text = SVGText::getInstance($this->startX - 30, $this->startY + $i, null, $this->maxY - $i); $text->setStyle("font-family:Arial"); $backGroup->addShape($text); } #horizontal counter for ($i = 0; $i <= $this->maxX; $i += 50) { $text = SVGText::getInstance($this->startX + $i, $this->startY + $this->maxY + 20, null, $i); $text->setStyle("font-family:Arial"); $backGroup->addShape($text); } $data = $this->getData(); $mainGroup = SVGGroup::getInstance('mainGroup'); $mainGroup->setStyle(new SVGStyle(array('clip-path' => 'url(#clipPath)'))); if (is_array($data)) { foreach ($data as $obj) { $itemData = $obj->data; $style = $obj->style; if (!$style) { $style = new SVGStyle(array('stroke' => 'blue', 'fill' => 'blue', 'stroke-width' => 1)); } if (is_array($itemData)) { foreach ($itemData as $line => $info) { $previous = $this->normalizeLineData(@$itemData[$line - 1]); $info = $this->normalizeLineData($info); $line = SVGLine::getInstance($previous[0], $previous[1], $info[0], $info[1], null, $style); //$this->addShape( $line ); $mainGroup->addShape($line); $circle = SVGCircle::getInstance($info[0], $info[1], 3, null, $style); $circle->setTitle($info[0] . ',' . $info[1]); $circle->addAttribute("onmouseover", "this.style.stroke = 'lightGray';"); $circle->addAttribute("onmouseout", "this.style.stroke = 'gray';"); //$this->addShape( $circle ); $mainGroup->addShape($circle); } } } } $this->addShape($backGroup); $this->addShape($mainGroup); $this->addScript("\n var width = \$('svg').attr('width').replace('px','');\n \$('svg #clippath rect').attr('width',0);\n var anim = setInterval('slideRight()', 1);\n\n function slideRight()\n {\n var currentWidth = parseInt( \$('svg #clippath rect').attr('width') );\n currentWidth += 1;\n\n \$('svg #clippath rect').attr('width',currentWidth );\n\n if ( currentWidth >= width )\n {\n clearInterval(anim);\n }\n }\n"); /* $this->addScript( " $('svg #mainGroup').hide(); setTimeout('showGraph()', 500); function showGraph() { $('svg #mainGroup').hide(); $('svg #mainGroup').show('slow'); }" ); */ }
$rect = SVGRect::getInstance(0, 5, 'myRect', 228, 185, new SVGStyle(array('fill' => 'red', 'stroke' => 'blue'))); #$rect->style->setFill('#f2f2f2'); //still not work #$rect->style->setStroke('#e1a100'); //still not work $rect->setWidth($svg->getWidth()); #make the rect of the size of pages $rect->skewX(5); #make a skew x transformation $rect->rotate(1); #make a rotation $rect->setRound(30); $svg->addShape($rect); #add the rect to svg $style = new SVGStyle(); $style->setFill('green'); $style->setStroke('black', 5); $circle = SVGCircle::getInstance(200, 100, 20, null, $style); $svg->addShape($circle); $ellipse = SVGEllipse::getInstance(200, 200, 100, 40); $ellipse->rotate(-30, 200, 200); $style2 = new SVGStyle(); $style2->setFill('none'); $style2->setStroke('blue', 3); $ellipse->setStyle($style2); $svg->addShape($ellipse); $style = new SVGStyle(); #create a style object #set fill and stroke $style->setFill('#f2f2f2'); $style->setStroke('#e1a100'); $style->setStrokeWidth(2); #create a text