public function testBarChartCreation() { $chart = new GridChart(); $chart->drawBars(array('label' => 'My bar', 'color' => 'black', 'data' => array(array(0, 0), array(1, 1), array(1, 2)))); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->loadXML($chart->render()); $xpath = new DOMXPath($doc); $xpath->registerNamespace('x', 'http://www.w3.org/2000/svg'); $path = $xpath->query('//x:rect[@data-icinga-graph-type="bar"]'); $this->assertEquals(6, $path->length, 'Assert the correct number of datapoints being drawn as SVG bars'); }
/** * Notifications and defects * * @return GridChart */ public function createDefectImage() { $gridChart = new GridChart(); $gridChart->title = $this->translate('Defect Chart'); $gridChart->description = $this->translate('Notifications and defects per hour'); $gridChart->alignTopLeft(); $gridChart->setAxisLabel($this->createPeriodDescription(), $this->translate('Notifications'))->setXAxis(new StaticAxis())->setYAxis(new LinearUnit(10))->setAxisMin(null, 0); $gridChart->drawBars(array('label' => $this->translate('Notifications'), 'color' => '#07C0D9', 'data' => $this->notificationData, 'showPoints' => true, 'tooltip' => '<b>{title}:</b> {value} {label}')); $gridChart->drawLines(array('label' => $this->translate('Defects'), 'color' => '#ff5566', 'data' => $this->problemData, 'showPoints' => true, 'tooltip' => '<b>{title}:</b> {value} {label}')); return $gridChart; }