diff --git a/library/Icinga/Chart/Axis.php b/library/Icinga/Chart/Axis.php index 264179ed6..83a3d08b1 100644 --- a/library/Icinga/Chart/Axis.php +++ b/library/Icinga/Chart/Axis.php @@ -29,14 +29,14 @@ namespace Icinga\Chart; -use \DOMElement; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\Primitive\Line; -use \Icinga\Chart\Primitive\Text; -use \Icinga\Chart\Render\RenderContext; -use \Icinga\Chart\Unit\AxisUnit; -use \Icinga\Chart\Unit\CalendarUnit; -use \Icinga\Chart\Unit\LinearUnit; +use DOMElement; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\Primitive\Line; +use Icinga\Chart\Primitive\Text; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Unit\AxisUnit; +use Icinga\Chart\Unit\CalendarUnit; +use Icinga\Chart\Unit\LinearUnit; /** * Axis class for the GridChart class. diff --git a/library/Icinga/Chart/Chart.php b/library/Icinga/Chart/Chart.php index 4e358da3b..d3ce9013e 100644 --- a/library/Icinga/Chart/Chart.php +++ b/library/Icinga/Chart/Chart.php @@ -29,11 +29,11 @@ namespace Icinga\Chart; -use \Exception; -use \Icinga\Chart\Legend; -use \Icinga\Chart\Palette; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\SVGRenderer; +use Exception; +use Icinga\Chart\Legend; +use Icinga\Chart\Palette; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\SVGRenderer; /** * Base class for charts, extended by all other Chart classes. diff --git a/library/Icinga/Chart/Graph/BarGraph.php b/library/Icinga/Chart/Graph/BarGraph.php index c29d13326..675aa76d2 100644 --- a/library/Icinga/Chart/Graph/BarGraph.php +++ b/library/Icinga/Chart/Graph/BarGraph.php @@ -29,12 +29,12 @@ namespace Icinga\Chart\Graph; -use \DOMElement; -use \Icinga\Chart\Primitive\Animation; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\Primitive\Rect; -use \Icinga\Chart\Primitive\Styleable; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Primitive\Animation; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\Primitive\Rect; +use Icinga\Chart\Primitive\Styleable; +use Icinga\Chart\Render\RenderContext; /** * Bar graph implementation @@ -94,7 +94,7 @@ class BarGraph extends Styleable implements Drawable $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 = new Rect($point[0] - 1, $point[1], 2, 100 - $point[1]); $rect->setFill($this->fill); $rect->setStrokeWidth($this->strokeWidth); $rect->setStrokeColor('black'); diff --git a/library/Icinga/Chart/Graph/LineGraph.php b/library/Icinga/Chart/Graph/LineGraph.php index 4bb06182b..cf3c9bcc1 100644 --- a/library/Icinga/Chart/Graph/LineGraph.php +++ b/library/Icinga/Chart/Graph/LineGraph.php @@ -30,12 +30,12 @@ namespace Icinga\Chart\Graph; -use \DOMElement; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\Primitive\Path; -use \Icinga\Chart\Primitive\Circle; -use \Icinga\Chart\Primitive\Styleable; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\Primitive\Path; +use Icinga\Chart\Primitive\Circle; +use Icinga\Chart\Primitive\Styleable; +use Icinga\Chart\Render\RenderContext; /** * LineGraph implementation for drawing a set of datapoints as diff --git a/library/Icinga/Chart/Graph/StackedGraph.php b/library/Icinga/Chart/Graph/StackedGraph.php index e63fae4a4..7a2152bab 100644 --- a/library/Icinga/Chart/Graph/StackedGraph.php +++ b/library/Icinga/Chart/Graph/StackedGraph.php @@ -29,9 +29,9 @@ namespace Icinga\Chart\Graph; -use \DOMElement; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\Render\RenderContext; /** * Graph implementation that stacks several graphs and displays them in a cumulative way diff --git a/library/Icinga/Chart/GridChart.php b/library/Icinga/Chart/GridChart.php index 4805d5ab7..c25cf5e65 100644 --- a/library/Icinga/Chart/GridChart.php +++ b/library/Icinga/Chart/GridChart.php @@ -29,18 +29,18 @@ namespace Icinga\Chart; -use \DOMElement; -use \Icinga\Chart\Chart; -use \Icinga\Chart\Axis; -use \Icinga\Chart\Graph\BarGraph; -use \Icinga\Chart\Graph\LineGraph; -use \Icinga\Chart\Graph\StackedGraph; -use \Icinga\Chart\Primitive\Canvas; -use \Icinga\Chart\Primitive\Rect; -use \Icinga\Chart\Primitive\Path; -use \Icinga\Chart\Render\LayoutBox; -use \Icinga\Chart\Render\RenderContext; -use \Icinga\Chart\Unit\AxisUnit; +use DOMElement; +use Icinga\Chart\Chart; +use Icinga\Chart\Axis; +use Icinga\Chart\Graph\BarGraph; +use Icinga\Chart\Graph\LineGraph; +use Icinga\Chart\Graph\StackedGraph; +use Icinga\Chart\Primitive\Canvas; +use Icinga\Chart\Primitive\Rect; +use Icinga\Chart\Primitive\Path; +use Icinga\Chart\Render\LayoutBox; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Unit\AxisUnit; /** * Base class for grid based charts. diff --git a/library/Icinga/Chart/Inline/Inline.php b/library/Icinga/Chart/Inline/Inline.php index 4f118134d..475f5b13f 100644 --- a/library/Icinga/Chart/Inline/Inline.php +++ b/library/Icinga/Chart/Inline/Inline.php @@ -40,7 +40,8 @@ namespace Icinga\Chart\Inline; * Class Inline * @package Icinga\Chart\Inline */ -class Inline { +class Inline +{ /** * The data displayed in this chart diff --git a/library/Icinga/Chart/Legend.php b/library/Icinga/Chart/Legend.php index a14648928..1ac9335c5 100644 --- a/library/Icinga/Chart/Legend.php +++ b/library/Icinga/Chart/Legend.php @@ -29,14 +29,14 @@ namespace Icinga\Chart; -use \DOMElement; -use \Icinga\Chart\Palette; -use \Icinga\Chart\Primitive\Canvas; -use \Icinga\Chart\Primitive\Drawable; -use \Icinga\Chart\Primitive\Rect; -use \Icinga\Chart\Primitive\Text; -use \Icinga\Chart\Render\LayoutBox; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Palette; +use Icinga\Chart\Primitive\Canvas; +use Icinga\Chart\Primitive\Drawable; +use Icinga\Chart\Primitive\Rect; +use Icinga\Chart\Primitive\Text; +use Icinga\Chart\Render\LayoutBox; +use Icinga\Chart\Render\RenderContext; /** * Drawable for creating a Graph Legend on the bottom of a graph. diff --git a/library/Icinga/Chart/PieChart.php b/library/Icinga/Chart/PieChart.php index f20cd6820..dc7066ad2 100644 --- a/library/Icinga/Chart/PieChart.php +++ b/library/Icinga/Chart/PieChart.php @@ -29,14 +29,14 @@ namespace Icinga\Chart; -use \DOMElement; -use \Icinga\Chart\Chart; -use \Icinga\Chart\Primitive\Canvas; -use \Icinga\Chart\Primitive\PieSlice; -use \Icinga\Chart\Primitive\RawElement; -use \Icinga\Chart\Primitive\Rect; -use \Icinga\Chart\Render\RenderContext; -use \Icinga\Chart\Render\LayoutBox; +use DOMElement; +use Icinga\Chart\Chart; +use Icinga\Chart\Primitive\Canvas; +use Icinga\Chart\Primitive\PieSlice; +use Icinga\Chart\Primitive\RawElement; +use Icinga\Chart\Primitive\Rect; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Render\LayoutBox; /** * Graphing component for rendering Pie Charts. diff --git a/library/Icinga/Chart/Primitive/Animatable.php b/library/Icinga/Chart/Primitive/Animatable.php index d319c154b..aadb80908 100644 --- a/library/Icinga/Chart/Primitive/Animatable.php +++ b/library/Icinga/Chart/Primitive/Animatable.php @@ -29,8 +29,8 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; /** * Base interface for animatable objects diff --git a/library/Icinga/Chart/Primitive/Animation.php b/library/Icinga/Chart/Primitive/Animation.php index b8b228a72..545f71da6 100644 --- a/library/Icinga/Chart/Primitive/Animation.php +++ b/library/Icinga/Chart/Primitive/Animation.php @@ -29,8 +29,8 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; /** * Drawable for the SVG animate tag diff --git a/library/Icinga/Chart/Primitive/Canvas.php b/library/Icinga/Chart/Primitive/Canvas.php index 6c92f181f..e33a2e20d 100644 --- a/library/Icinga/Chart/Primitive/Canvas.php +++ b/library/Icinga/Chart/Primitive/Canvas.php @@ -30,9 +30,9 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\LayoutBox; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\LayoutBox; +use Icinga\Chart\Render\RenderContext; /** * Canvas SVG component that encapsulates grouping and padding and allows rendering diff --git a/library/Icinga/Chart/Primitive/Circle.php b/library/Icinga/Chart/Primitive/Circle.php index 853eef11a..4d9d75a36 100644 --- a/library/Icinga/Chart/Primitive/Circle.php +++ b/library/Icinga/Chart/Primitive/Circle.php @@ -30,8 +30,9 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Format; /** * Drawable for svg circles diff --git a/library/Icinga/Chart/Primitive/Drawable.php b/library/Icinga/Chart/Primitive/Drawable.php index d96771f0c..69b937b7d 100644 --- a/library/Icinga/Chart/Primitive/Drawable.php +++ b/library/Icinga/Chart/Primitive/Drawable.php @@ -29,8 +29,8 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; /** * Drawable element for creating svg out of components diff --git a/library/Icinga/Chart/Primitive/Line.php b/library/Icinga/Chart/Primitive/Line.php index 47aca0316..b3a5d7f77 100644 --- a/library/Icinga/Chart/Primitive/Line.php +++ b/library/Icinga/Chart/Primitive/Line.php @@ -29,8 +29,9 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Format; /** * Drawable for the svg line element diff --git a/library/Icinga/Chart/Primitive/RawElement.php b/library/Icinga/Chart/Primitive/RawElement.php index 7a520beb9..be0f6c3ee 100644 --- a/library/Icinga/Chart/Primitive/RawElement.php +++ b/library/Icinga/Chart/Primitive/RawElement.php @@ -29,8 +29,8 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; -use \Icinga\Chart\Render\RenderContext; +use DOMElement; +use Icinga\Chart\Render\RenderContext; /** * Wrapper for raw elements to be added as Drawable's diff --git a/library/Icinga/Chart/Primitive/Styleable.php b/library/Icinga/Chart/Primitive/Styleable.php index 28bf69979..9b4a4f59b 100644 --- a/library/Icinga/Chart/Primitive/Styleable.php +++ b/library/Icinga/Chart/Primitive/Styleable.php @@ -30,7 +30,7 @@ namespace Icinga\Chart\Primitive; -use \DOMElement; +use DOMElement; /** * Base class for stylable drawables diff --git a/library/Icinga/Chart/SVGRenderer.php b/library/Icinga/Chart/SVGRenderer.php index bd9b8d47b..eca1ce99c 100644 --- a/library/Icinga/Chart/SVGRenderer.php +++ b/library/Icinga/Chart/SVGRenderer.php @@ -29,14 +29,13 @@ namespace Icinga\Chart; -use \DOMNode; -use \DOMElement; -use \DOMDocument; -use \DOMImplementation; -use \Icinga\Util\Dimension; -use \Icinga\Chart\Render\LayoutBox; -use \Icinga\Chart\Render\RenderContext; -use \Icinga\Chart\Primitive\Canvas; +use DOMNode; +use DOMElement; +use DOMDocument; +use DOMImplementation; +use Icinga\Chart\Render\LayoutBox; +use Icinga\Chart\Render\RenderContext; +use Icinga\Chart\Primitive\Canvas; /** * SVG Renderer component. diff --git a/library/Icinga/Chart/Unit/CalendarUnit.php b/library/Icinga/Chart/Unit/CalendarUnit.php index a3bfe1216..8da617ea6 100644 --- a/library/Icinga/Chart/Unit/CalendarUnit.php +++ b/library/Icinga/Chart/Unit/CalendarUnit.php @@ -30,10 +30,7 @@ namespace Icinga\Chart\Unit; -use \Zend_Config; -use \Icinga\Application\Icinga; -use \Icinga\Application\Config as IcingaConfig; -use \Icinga\Util\DateTimeFactory; +use Icinga\Util\DateTimeFactory; /** * Calendar Axis Unit that transforms timestamps into user-readable values diff --git a/library/Icinga/Chart/Unit/StaticAxis.php b/library/Icinga/Chart/Unit/StaticAxis.php index 07bbf4a2a..2d776f3b8 100644 --- a/library/Icinga/Chart/Unit/StaticAxis.php +++ b/library/Icinga/Chart/Unit/StaticAxis.php @@ -35,10 +35,12 @@ class StaticAxis implements AxisUnit private $items = array(); /** - * Add a dataset to this AxisUnit, required for dynamic min and max vlaues + * Add a dataset to this AxisUnit, required for dynamic min and max values * * @param array $dataset The dataset that will be shown in the Axis - * @param int $id The idx in the dataset (0 for x, 1 for y) + * @param int $idx The idx in the dataset (0 for x, 1 for y) + * + * @return self Fluent interface */ public function addValues(array $dataset, $idx = 0) { diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index acb84a8f0..4e2cda313 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -47,15 +47,15 @@ use Icinga\Chart\Unit\StaticAxis; class Monitoring_ChartController extends Controller { - public function testAction() { + public function testAction() + { $this->chart = new GridChart(); $this->chart->setAxisLabel('X axis label', 'Y axis label')->setXAxis(new StaticAxis()); $data1 = array(); $data2 = array(); $data3 = array(); - for ($i=0; $i<25; $i++) { - - $data3[] = array('Label ' . $i, rand(0,30)); + for ($i = 0; $i < 25; $i++) { + $data3[] = array('Label ' . $i, rand(0, 30)); } /* @@ -200,9 +200,18 @@ class Monitoring_ChartController extends Controller $downBars = array(); $unreachableBars = array(); foreach ($query as $hostgroup) { - $upBars[] = array($hostgroup->hostgroup, $hostgroup->hosts_up); - $downBars[] = array($hostgroup->hostgroup, $hostgroup->hosts_down_unhandled); - $unreachableBars[] = array($hostgroup->hostgroup, $hostgroup->hosts_unreachable_unhandled); + $upBars[] = array( + $hostgroup->hostgroup, + $hostgroup->hosts_up + ); + $downBars[] = array( + $hostgroup->hostgroup, + $hostgroup->hosts_down_unhandled + ); + $unreachableBars[] = array( + $hostgroup->hostgroup, + $hostgroup->hosts_unreachable_unhandled + ); } $this->view->chart = new GridChart(); $this->view->chart->setAxisLabel('', 'Hosts')->setXAxis(new StaticAxis());