/** * Draw a single rectangle * * @param array $point The * @param null $index * @param string $fill The fill color to use * @param $strokeWidth * * @return Rect */ private function drawSingleBar($point, $index = null, $fill, $strokeWidth) { $rect = new Rect($point[0] - $this->barWidth / 2, $point[1], $this->barWidth, 100 - $point[1]); $rect->setFill($fill); $rect->setStrokeWidth($strokeWidth); $rect->setStrokeColor('black'); if (isset($index)) { $rect->setAttribute('data-icinga-graph-index', $index); } $rect->setAttribute('data-icinga-graph-type', 'bar'); $rect->setAdditionalStyle('clip-path: url(#clip);'); return $rect; }
/** * Render this BarChart * * @param RenderContext $ctx The rendering context to use for drawing * * @return DOMElement $dom Element */ public function toSvg(RenderContext $ctx) { $doc = $ctx->getDocument(); $group = $doc->createElement('g'); $idx = 0; foreach ($this->dataSet as $point) { $rect = new Rect($point[0] - 1, $point[1], $this->barWidth, 100 - $point[1]); $rect->setFill($this->fill); $rect->setStrokeWidth($this->strokeWidth); $rect->setStrokeColor('black'); $rect->setAttribute('data-icinga-graph-index', $idx++); $rect->setAttribute('data-icinga-graph-type', 'bar'); $rect->setAdditionalStyle('clip-path: url(#clip);'); /*$rect->setAnimation( new Animation( 'y', $ctx->yToAbsolute(100), $ctx->yToAbsolute($point[1]), rand(1, 1.5)/2 ) );*/ $group->appendChild($rect->toSvg($ctx)); } return $group; }