mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 04:44:25 +02:00
Icinga/Chart: Fixes typo, doc, interfaces, inspection warnings
refs #4614
This commit is contained in:
parent
7690b0ec7f
commit
c6838f67a1
@ -6,7 +6,7 @@ Icinga Web comes with an SVG based graphing library that supports the basic grap
|
||||
data. These include:
|
||||
|
||||
* **Pie Charts**, which display a set of data in a typical pie diagram.
|
||||
* **Stacked Pie Charts**, which render one or multiple pies nested in anothe pie chart
|
||||
* **Stacked Pie Charts**, which render one or multiple pies nested in another pie chart
|
||||
* **Line Charts**, which display a set of datapoints as a line graph
|
||||
* **Stacked Line Charts**, which display multiple line charts on top of each other, providing a cumulative view over
|
||||
a set of datapoints
|
||||
@ -18,7 +18,7 @@ data. These include:
|
||||
### Base Api Synopsis
|
||||
|
||||
The `Icinga/Chart/GridChart` class provides the calls required for setting up Grid Charts. A GridChart draws three
|
||||
seperate parts: Axis, Legend and the Gridarea.
|
||||
separate parts: Axis, Legend and the Gridarea.
|
||||
|
||||
To create a new Grid, simply create a `GridChart` object (the constructor takes no parameters):
|
||||
|
||||
@ -146,7 +146,7 @@ are:
|
||||
'Dataset %nr%' will be displayed, with %nr% meaning a number starting at 1 and incrementing for every
|
||||
line without a label
|
||||
* **stack** If provided, this graph will be shown on top of each other graph in the same stack and causes all
|
||||
graphs in the same stack to be rendered culmulative
|
||||
graphs in the same stack to be rendered cumulative
|
||||
* **discrete** Set to display the line in a discrete manner, i.e. using hard steps between values instead of drawing
|
||||
a interpolated line between points
|
||||
* **color** The color to use for the line or fill, either in Hex form or as a string supported in the SVG style tag
|
||||
@ -203,7 +203,7 @@ while '...' means 'as many definitions as you want'. Possible configuration opti
|
||||
'Dataset %nr%' will be displayed, with %nr% meaning a number starting at 1 and incrementing for every
|
||||
line without a label
|
||||
* **stack** If provided, this graph will be shown on top of each other graph in the same stack and causes all
|
||||
graphs in the same stack to be rendered culmulative
|
||||
graphs in the same stack to be rendered cumulative
|
||||
* **color** The color to use for filling the bar, either in Hex form or as a string supported in the SVG style tag
|
||||
* **palette** (Ignored if 'color' is set) The color palette to use for determining the fill color
|
||||
* **width** Set the thickness of the line stroke in px (default: 1)
|
||||
|
@ -1,18 +1,41 @@
|
||||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
*
|
||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Chart;
|
||||
|
||||
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 \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.
|
||||
@ -228,9 +251,9 @@ class Axis implements Drawable
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label for the x axis.
|
||||
* Set the label for the x axis
|
||||
*
|
||||
* An empty string means 'no label'
|
||||
* An empty string means 'no label'.
|
||||
*
|
||||
* @param string $label The label to use for the x axis
|
||||
*
|
||||
@ -243,13 +266,13 @@ class Axis implements Drawable
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label for the y axis.
|
||||
* Set the label for the y axis
|
||||
*
|
||||
* An empty string means 'no label'
|
||||
* An empty string means 'no label'.
|
||||
*
|
||||
* @param string $label The label to use for the y axis
|
||||
*
|
||||
* @return $this Fluid interface
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setYLabel($label)
|
||||
{
|
||||
@ -262,9 +285,9 @@ class Axis implements Drawable
|
||||
*
|
||||
* Setting the value to null let's the axis unit decide which value to use for the minimum
|
||||
*
|
||||
* @param mixed $label The minimum value to use for the x axis
|
||||
* @param int $xMin The minimum value to use for the x axis
|
||||
*
|
||||
* @return $this Fluid interface
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setXMin($xMin)
|
||||
{
|
||||
@ -277,9 +300,9 @@ class Axis implements Drawable
|
||||
*
|
||||
* Setting the value to null let's the axis unit decide which value to use for the minimum
|
||||
*
|
||||
* @param mixed $label The minimum value to use for the x axis
|
||||
* @param int $yMin The minimum value to use for the x axis
|
||||
*
|
||||
* @return $this Fluid interface
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setYMin($yMin)
|
||||
{
|
||||
@ -292,9 +315,9 @@ class Axis implements Drawable
|
||||
*
|
||||
* Setting the value to null let's the axis unit decide which value to use for the maximum
|
||||
*
|
||||
* @param mixed $label The minimum value to use for the x axis
|
||||
* @param int $xMax The minimum value to use for the x axis
|
||||
*
|
||||
* @return $this Fluid interface
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setXMax($xMax)
|
||||
{
|
||||
@ -307,9 +330,9 @@ class Axis implements Drawable
|
||||
*
|
||||
* Setting the value to null let's the axis unit decide which value to use for the maximum
|
||||
*
|
||||
* @param mixed $label The minimum value to use for the y axis
|
||||
* @param int $yMax The minimum value to use for the y axis
|
||||
*
|
||||
* @return $this Fluid interface
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setYMax($yMax)
|
||||
{
|
||||
@ -364,7 +387,6 @@ class Axis implements Drawable
|
||||
* @param RenderContext $ctx The context to use for calculations
|
||||
*
|
||||
* @return DOMElement
|
||||
*
|
||||
* @see Drawable::toSvg
|
||||
*/
|
||||
public function toSvg(RenderContext $ctx)
|
||||
|
@ -28,11 +28,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.
|
||||
@ -76,7 +76,6 @@ abstract class Chart implements Drawable
|
||||
|
||||
/**
|
||||
* Extension point for subclasses, called on __construct
|
||||
*
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
|
@ -28,13 +28,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
|
||||
@ -43,6 +42,7 @@ class BarGraph extends Styleable implements Drawable
|
||||
{
|
||||
/**
|
||||
* The dataset to use for this bar graph
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $dataSet;
|
||||
|
@ -29,11 +29,12 @@
|
||||
|
||||
namespace Icinga\Chart\Graph;
|
||||
|
||||
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
|
||||
@ -43,18 +44,21 @@ class LineGraph extends Styleable implements Drawable
|
||||
{
|
||||
/**
|
||||
* The dataset to use
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $dataset;
|
||||
|
||||
/**
|
||||
* True to show dots for each datapoint
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $showDataPoints = false;
|
||||
|
||||
/**
|
||||
* When true, the path will be discrete, i.e. showing hard steps instead of a direct line
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $isDiscrete = false;
|
||||
@ -79,7 +83,7 @@ class LineGraph extends Styleable implements Drawable
|
||||
/**
|
||||
* Set datapoints to be emphased via dots
|
||||
*
|
||||
* @param $bool True to enable datapoints, otherwise false
|
||||
* @param bool $bool True to enable datapoints, otherwise false
|
||||
*/
|
||||
public function setShowDataPoints($bool)
|
||||
{
|
||||
|
@ -28,8 +28,9 @@
|
||||
|
||||
namespace Icinga\Chart\Graph;
|
||||
|
||||
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
|
||||
|
@ -28,19 +28,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.
|
||||
@ -120,6 +119,8 @@ class GridChart extends Chart
|
||||
|
||||
/**
|
||||
* Calls Axis::addDataset for every graph added to this GridChart
|
||||
*
|
||||
* @see Axis::addDataset
|
||||
*/
|
||||
private function configureAxisFromDatasets()
|
||||
{
|
||||
@ -132,30 +133,29 @@ class GridChart extends Chart
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an arbitary number of lines to be drawn
|
||||
* Add an arbitrary number of lines to be drawn
|
||||
*
|
||||
* Refer to the graphs.md for a detailed list of allowed attributes
|
||||
*
|
||||
* @param array $axix The line definitions to draw
|
||||
* @param array ...
|
||||
* @param array $axis,... The line definitions to draw
|
||||
*
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function drawLines($axis /*,...*/)
|
||||
public function drawLines(array $axis)
|
||||
{
|
||||
$this->draw(self::TYPE_LINE, func_get_args());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add arbitary number of bars to be drawn
|
||||
* Add arbitrary number of bars to be drawn
|
||||
*
|
||||
* Refer to the graphs.md for a detailed list of allowed attributes
|
||||
*
|
||||
* @param $axis
|
||||
* @return $this
|
||||
* @param array $axis
|
||||
* @return self
|
||||
*/
|
||||
public function drawBars($axis)
|
||||
public function drawBars(array $axis)
|
||||
{
|
||||
$this->draw(self::TYPE_BAR, func_get_args());
|
||||
return $this;
|
||||
@ -164,7 +164,7 @@ class GridChart extends Chart
|
||||
/**
|
||||
* Generic method for adding elements to the drawing stack
|
||||
*
|
||||
* @param Srring $type The type of the element to draw (see TYPE_ constants in this class)
|
||||
* @param string $type The type of the element to draw (see TYPE_ constants in this class)
|
||||
* @param array $data The data given to the draw call
|
||||
*/
|
||||
private function draw($type, $data)
|
||||
@ -290,8 +290,8 @@ class GridChart extends Chart
|
||||
*
|
||||
* Setting null to an axis means this will use a value determined by the dataset
|
||||
*
|
||||
* @param int|null $xMin The minimum value for the x axis or null to use a dynamic value
|
||||
* @param int|null $yMin The minimum value for the y axis or null to use a dynamic value
|
||||
* @param int $xMin The minimum value for the x axis or null to use a dynamic value
|
||||
* @param int $yMin The minimum value for the y axis or null to use a dynamic value
|
||||
* @param string $axisName The name of the axis to set the minimum, currently only 'default'
|
||||
*
|
||||
* @return self Fluid interface
|
||||
@ -307,8 +307,8 @@ class GridChart extends Chart
|
||||
*
|
||||
* Setting null to an axis means this will use a value determined by the dataset
|
||||
*
|
||||
* @param int|null $xMax The maximum value for the x axis or null to use a dynamic value
|
||||
* @param int|null $yMax The maximum value for the y axis or null to use a dynamic value
|
||||
* @param int $xMax The maximum value for the x axis or null to use a dynamic value
|
||||
* @param int $yMax The maximum value for the y axis or null to use a dynamic value
|
||||
* @param string $axisName The name of the axis to set the maximum, currently only 'default'
|
||||
*
|
||||
* @return self Fluid interface
|
||||
@ -376,6 +376,7 @@ class GridChart extends Chart
|
||||
{
|
||||
foreach ($this->graphs as $axisName => $graphs) {
|
||||
$axis = $this->axis[$axisName];
|
||||
$graphObj = null;
|
||||
foreach ($graphs as $graph) {
|
||||
// determine the type and create a graph object for it
|
||||
switch ($graph['graphType']) {
|
||||
@ -402,7 +403,7 @@ class GridChart extends Chart
|
||||
* @param mixed $graphObject The graph class, needs the setStyleFromConfig method
|
||||
* @param array $graphConfig The configration array of the graph
|
||||
*
|
||||
* @return null|mixed Either the graph to be added or null if the graph is not directly added
|
||||
* @return mixed Either the graph to be added or null if the graph is not directly added
|
||||
* to the document (e.g. stacked graphs are added by
|
||||
* the StackedGraph Composite object)
|
||||
*/
|
||||
@ -415,7 +416,7 @@ class GridChart extends Chart
|
||||
if (!$graphConfig['stack']->stackEmpty()) {
|
||||
return $graphConfig['stack'];
|
||||
}
|
||||
// return no object when the graph shouldn be rendered
|
||||
// return no object when the graph should not be rendered
|
||||
return null;
|
||||
}
|
||||
return $graphObject;
|
||||
|
@ -28,15 +28,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.
|
||||
@ -109,7 +108,8 @@ class Legend implements Drawable
|
||||
}
|
||||
|
||||
$colorBox = new Rect($left, $top, 2, 2);
|
||||
$colorBox->setFill($color)->setStrokeWidth(2)->keepRatio();
|
||||
$colorBox->setFill($color)->setStrokeWidth(2);
|
||||
$colorBox->keepRatio();
|
||||
$outer->addElement($colorBox);
|
||||
|
||||
$textBox = new Text($left+5, $top+2, $text);
|
||||
|
@ -1,5 +1,29 @@
|
||||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
*
|
||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Chart;
|
||||
|
@ -1,18 +1,41 @@
|
||||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga 2 Web.
|
||||
*
|
||||
* Icinga 2 Web - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
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.
|
||||
@ -95,14 +118,13 @@ class PieChart extends Chart
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw an arbitary number of pies in this chart
|
||||
* Draw an arbitrary number of pies in this chart
|
||||
*
|
||||
* @param $dataSet The pie definition, see graphs.md for further details concerning the format
|
||||
* @param ...
|
||||
* @param array $dataSet,... The pie definition, see graphs.md for further details concerning the format
|
||||
*
|
||||
* @return self Fluent interface
|
||||
*/
|
||||
public function drawPie($dataSet)
|
||||
public function drawPie(array $dataSet)
|
||||
{
|
||||
$dataSets = func_get_args();
|
||||
$this->pies += $dataSets;
|
||||
|
@ -28,11 +28,11 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use DOMElement;
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Base interace for animatable objects
|
||||
* Base interface for animatable objects
|
||||
*/
|
||||
abstract class Animatable extends Styleable
|
||||
{
|
||||
@ -56,7 +56,7 @@ abstract class Animatable extends Styleable
|
||||
/**
|
||||
* Append the animation to the given element
|
||||
*
|
||||
* @param DOMElement $dom The element to append the animstion to
|
||||
* @param DOMElement $dom The element to append the animation to
|
||||
* @param RenderContext $ctx The context to use for rendering the animation object
|
||||
*/
|
||||
protected function appendAnimation(DOMElement $dom, RenderContext $ctx)
|
||||
|
@ -28,8 +28,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
|
||||
@ -38,6 +38,7 @@ class Animation implements Drawable
|
||||
{
|
||||
/**
|
||||
* The attribute to animate
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $attribute;
|
||||
@ -79,7 +80,7 @@ class Animation implements Drawable
|
||||
* @param float $duration The duration of the duration
|
||||
* @param float $begin The begin of the duration
|
||||
*/
|
||||
public function __construct($attribute, $from, $to, $duration = 0.5, $begin = 0)
|
||||
public function __construct($attribute, $from, $to, $duration = 0.5, $begin = 0.0)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
$this->from = $from;
|
||||
|
@ -29,8 +29,9 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
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
|
||||
@ -41,24 +42,28 @@ class Canvas implements Drawable
|
||||
{
|
||||
/**
|
||||
* The name of the canvas, will be used as the id
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* An array of child elements of this Canvas
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $children = array();
|
||||
|
||||
/**
|
||||
* When true, this canvas is encapsulated in a clipPath tag and not drawn
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $isClipPath = false;
|
||||
|
||||
/**
|
||||
* The LayoutBox of this Canvas
|
||||
*
|
||||
* @var LayoutBox
|
||||
*/
|
||||
private $rect;
|
||||
|
@ -29,7 +29,8 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Drawable for svg circles
|
||||
@ -38,18 +39,21 @@ class Circle extends Styleable implements Drawable
|
||||
{
|
||||
/**
|
||||
* The circles x position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $x;
|
||||
|
||||
/**
|
||||
* The circles y position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $y;
|
||||
|
||||
/**
|
||||
* The circles radius
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $radius;
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Drawable element for creating svg out of components
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Drawable for the svg line element
|
||||
@ -45,24 +46,28 @@ class Line extends Styleable implements Drawable
|
||||
|
||||
/**
|
||||
* The line's start x coordinate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $xStart = 0;
|
||||
|
||||
/**
|
||||
* The line's end x coordinate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $xEnd = 0;
|
||||
|
||||
/**
|
||||
* The line's start y coordinate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $yStart = 0;
|
||||
|
||||
/**
|
||||
* The line's end y coordinate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $yEnd = 0;
|
||||
|
@ -28,26 +28,46 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Drawable for creating a svg path element
|
||||
*/
|
||||
class Path extends Styleable implements Drawable
|
||||
{
|
||||
/**
|
||||
* Syntax template for moving
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands
|
||||
*/
|
||||
const TPL_MOVE = 'M %s %s ';
|
||||
|
||||
const TPL_MOVE = "M %s %s ";
|
||||
const TPL_BEZIER = "S %s %s ";
|
||||
const TPL_STRAIGHT = "L %s %s ";
|
||||
/**
|
||||
* Syntax template for bezier curve
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
|
||||
*/
|
||||
const TPL_BEZIER = 'S %s %s ';
|
||||
|
||||
/**
|
||||
* Syntax template for straight lines
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands
|
||||
*/
|
||||
const TPL_STRAIGHT = 'L %s %s ';
|
||||
|
||||
/**
|
||||
* The default stroke width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $strokeWidth = 1;
|
||||
|
||||
/**
|
||||
* True to treat coordinates as absolute values
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isAbsolute = false;
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use DOMElement;
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DOMElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Component for drawing a pie slice
|
||||
@ -38,36 +38,42 @@ class PieSlice extends Animatable implements Drawable
|
||||
{
|
||||
/**
|
||||
* The radius of this pieslice relative to the canvas
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $radius = 50;
|
||||
|
||||
/**
|
||||
* The start radian of the pie slice
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $startRadian = 0;
|
||||
|
||||
/**
|
||||
* The end radian of the pie slice
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $endRadian= 0;
|
||||
|
||||
/**
|
||||
* The x position of the pie slice's center
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $x;
|
||||
|
||||
/**
|
||||
* The y position of the pie slice's center
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $y;
|
||||
|
||||
/**
|
||||
* The caption of the pie slice, empty string means no caption
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $caption = "";
|
||||
@ -75,19 +81,22 @@ class PieSlice extends Animatable implements Drawable
|
||||
/**
|
||||
* The offset of the caption, shifting the indicator from the center of the pie slice
|
||||
*
|
||||
* This is required for nested pie slices
|
||||
* This is required for nested pie slices.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $captionOffset = 0;
|
||||
|
||||
/**
|
||||
* The minimum radius the label must respect
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $outerCaptionBound = 0;
|
||||
|
||||
/**
|
||||
* An optional group element to add labels to when rendering
|
||||
*
|
||||
* @var DOMElement
|
||||
*/
|
||||
private $labelGroup;
|
||||
|
@ -28,8 +28,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
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use \DomElement;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Drawable representing the SVG rect element
|
||||
@ -37,30 +38,35 @@ class Rect extends Animatable implements Drawable
|
||||
{
|
||||
/**
|
||||
* The x position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $x;
|
||||
|
||||
/**
|
||||
* The y position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $y;
|
||||
|
||||
/**
|
||||
* The width of this rect
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $width;
|
||||
|
||||
/**
|
||||
* The height of this rect
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $height;
|
||||
|
||||
/**
|
||||
* Whether to keep the ratio
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $keepRatio = false;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
use DOMElement;
|
||||
use \DOMElement;
|
||||
|
||||
/**
|
||||
* Base class for stylable drawables
|
||||
@ -39,30 +39,35 @@ class Styleable
|
||||
|
||||
/**
|
||||
* The stroke width to use
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $strokeWidth = 0;
|
||||
|
||||
/**
|
||||
* The stroke color to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $strokeColor = '#000';
|
||||
|
||||
/**
|
||||
* The fill color to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $fill = 'none';
|
||||
|
||||
/**
|
||||
* Additional styles to be appended to the style attribute
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $additionalStyle = '';
|
||||
|
||||
/**
|
||||
* The id of this element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id = null;
|
||||
@ -77,7 +82,7 @@ class Styleable
|
||||
/**
|
||||
* Set the stroke width for this drawable
|
||||
*
|
||||
* @param string $stroke The stroke with with unit
|
||||
* @param string $width The stroke with with unit
|
||||
*
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
@ -143,7 +148,7 @@ class Styleable
|
||||
/**
|
||||
* Return the content of the style attribute as a string
|
||||
*
|
||||
* @return string T
|
||||
* @return string A string containing styles
|
||||
*/
|
||||
public function getStyle()
|
||||
{
|
||||
@ -153,13 +158,18 @@ class Styleable
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an additional attribte to this element
|
||||
* Add an additional attribute to this element
|
||||
*/
|
||||
public function setAttribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply attribute to a DOMElement
|
||||
*
|
||||
* @param DOMElement $el Element to apply attributes
|
||||
*/
|
||||
protected function applyAttributes(DOMElement $el)
|
||||
{
|
||||
foreach ($this->attributes as $name => $value) {
|
||||
|
@ -29,9 +29,9 @@
|
||||
|
||||
namespace Icinga\Chart\Primitive;
|
||||
|
||||
|
||||
use Icinga\Chart\Render\RenderContext;
|
||||
use DOMText;
|
||||
use \DOMElement;
|
||||
use \DOMText;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
|
||||
/**
|
||||
* Wrapper for the SVG text element
|
||||
@ -65,36 +65,42 @@ class Text extends Styleable implements Drawable
|
||||
|
||||
/**
|
||||
* The x position of the Text
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $x;
|
||||
|
||||
/**
|
||||
* The y position of the Text
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $y;
|
||||
|
||||
/**
|
||||
* The text content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $text;
|
||||
|
||||
/**
|
||||
* The size of the font
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fontSize = '1.5em';
|
||||
|
||||
/**
|
||||
* The default fill color
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $fill = '#000';
|
||||
|
||||
/**
|
||||
* The alignment of the text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $alignment = self::ALIGN_START;
|
||||
@ -131,9 +137,9 @@ class Text extends Styleable implements Drawable
|
||||
/**
|
||||
* Set the the text alignment with one of the ALIGN_* constants
|
||||
*
|
||||
* @param String $align
|
||||
* @param String $align Value how to align
|
||||
*
|
||||
* @return self
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function setAlignment($align)
|
||||
{
|
||||
|
@ -29,8 +29,8 @@
|
||||
|
||||
namespace Icinga\Chart\Render;
|
||||
|
||||
use Icinga\Util\Dimension;
|
||||
use DOMDocument;
|
||||
use \DOMDocument;
|
||||
use \Icinga\Util\Dimension;
|
||||
|
||||
/**
|
||||
* Context for rendering, handles ratio based coordinate calculations.
|
||||
@ -63,20 +63,6 @@ class RenderContext
|
||||
*/
|
||||
private $respectRatio = false;
|
||||
|
||||
/**
|
||||
* The current padding (scale) factor on the X axis
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $paddingFacX = 1;
|
||||
|
||||
/**
|
||||
* The current padding (scale) factor on the Y Axis
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $paddingFacY = 1;
|
||||
|
||||
/**
|
||||
* The ratio on the x side. A x ration of 2 means that the width of the SVG is divided in 2000
|
||||
* units (see $viewBox)
|
||||
@ -123,9 +109,9 @@ class RenderContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Let successive toAbsolute operations ignore ratio correction.
|
||||
* Let successive toAbsolute operations ignore ratio correction
|
||||
*
|
||||
* This can be called to avoid distortion on certain elements like rectangles
|
||||
* This can be called to avoid distortion on certain elements like rectangles.
|
||||
*/
|
||||
public function keepRatio()
|
||||
{
|
||||
@ -135,7 +121,7 @@ class RenderContext
|
||||
/**
|
||||
* Let successive toAbsolute operations perform ratio correction
|
||||
*
|
||||
* This will cause distortion on certain elements like rectangles
|
||||
* This will cause distortion on certain elements like rectangles.
|
||||
*/
|
||||
public function ignoreRatio()
|
||||
{
|
||||
@ -220,7 +206,7 @@ class RenderContext
|
||||
*
|
||||
* @param int $x A relative x coordinate
|
||||
*
|
||||
* @return int $y An absolute x coordinate
|
||||
* @return int An absolute x coordinate
|
||||
**/
|
||||
public function xToAbsolute($x)
|
||||
{
|
||||
@ -232,7 +218,7 @@ class RenderContext
|
||||
*
|
||||
* @param int $y A relative y coordinate
|
||||
*
|
||||
* @return int $y An absolute y coordinate
|
||||
* @return int An absolute y coordinate
|
||||
*/
|
||||
public function yToAbsolute($y)
|
||||
{
|
||||
@ -244,7 +230,7 @@ class RenderContext
|
||||
*
|
||||
* @param int $x An absolute x coordinate
|
||||
*
|
||||
* @return int $x A relative x coordinate
|
||||
* @return int A relative x coordinate
|
||||
*/
|
||||
public function xToRelative($x)
|
||||
{
|
||||
@ -256,7 +242,7 @@ class RenderContext
|
||||
*
|
||||
* @param int $y An absolute x coordinate
|
||||
*
|
||||
* @return int $y A relative x coordinate
|
||||
* @return int A relative x coordinate
|
||||
*/
|
||||
public function yToRelative($y)
|
||||
{
|
||||
|
@ -28,21 +28,19 @@
|
||||
|
||||
namespace Icinga\Chart;
|
||||
|
||||
use DOMNode;
|
||||
use DOMElement;
|
||||
use DOMDocument;
|
||||
use DOMImplementation;
|
||||
use Exception;
|
||||
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\Util\Dimension;
|
||||
use \Icinga\Chart\Render\LayoutBox;
|
||||
use \Icinga\Chart\Render\RenderContext;
|
||||
use \Icinga\Chart\Primitive\Canvas;
|
||||
|
||||
/**
|
||||
* SVG Renderer component.
|
||||
*
|
||||
* Creates the basic DOM tree of the SVG to use
|
||||
*
|
||||
*/
|
||||
class SVGRenderer
|
||||
{
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
namespace Icinga\Chart\Unit;
|
||||
|
||||
use Iterator;
|
||||
use \Iterator;
|
||||
|
||||
/**
|
||||
* Base class for Axis Units
|
||||
@ -51,9 +51,23 @@ interface AxisUnit extends Iterator
|
||||
/**
|
||||
* Transform the given absolute value in an axis relative value
|
||||
*
|
||||
* @param int $value The absolute, dataset dependend value
|
||||
* @param int $value The absolute, dataset dependent value
|
||||
*
|
||||
* @return int An axis relative value
|
||||
*/
|
||||
public function transform($value);
|
||||
|
||||
/**
|
||||
* Set the axis minimum value to a fixed value
|
||||
*
|
||||
* @param int $min The new minimum value
|
||||
*/
|
||||
public function setMin($min);
|
||||
|
||||
/**
|
||||
* Set the axis maximum value to a fixed value
|
||||
*
|
||||
* @param int $max The new maximum value
|
||||
*/
|
||||
public function setMax($max);
|
||||
}
|
||||
|
@ -29,10 +29,10 @@
|
||||
|
||||
namespace Icinga\Chart\Unit;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Zend_Config;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use \Zend_Config;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
|
||||
/**
|
||||
* Calendar Axis Unit that transforms timestamps into user-readable values
|
||||
@ -138,7 +138,7 @@ class CalendarUnit extends LinearUnit
|
||||
* @param array $dataset The dataset to update
|
||||
* @param int $idx The index to use for determining the data
|
||||
*
|
||||
* @return self
|
||||
* @return self Fluid interface
|
||||
*/
|
||||
public function addValues(array $dataset, $idx = 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user