dataSet = $dataSet; } /** * Apply configuration styles from the $cfg * * @param array $cfg The configuration as given in the drawBars call */ public function setStyleFromConfig(array $cfg) { foreach ($cfg as $elem => $value) { if ($elem === 'color') { $this->setFill($value); } elseif ($elem === 'width') { $this->setStrokeWidth($value); } } } /** * 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], 2, 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; } }