parent
f5e4331d71
commit
f7c6cd3c2a
|
@ -16,6 +16,7 @@ class Monitoring_TimelineController extends ActionController
|
||||||
{
|
{
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
// TODO: filter for hard_states (precedence adjustments necessary!)
|
||||||
$this->setupIntervalBox();
|
$this->setupIntervalBox();
|
||||||
list($displayRange, $forecastRange) = $this->buildTimeRanges();
|
list($displayRange, $forecastRange) = $this->buildTimeRanges();
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ class Monitoring_TimelineController extends ActionController
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$timeline->setMaximumCircleWidth('6em');
|
$timeline->setMaximumCircleWidth('6em');
|
||||||
|
$timeline->setMinimumCircleWidth('0.15em');
|
||||||
$timeline->setDisplayRange($displayRange);
|
$timeline->setDisplayRange($displayRange);
|
||||||
$timeline->setForecastRange($forecastRange);
|
$timeline->setForecastRange($forecastRange);
|
||||||
$timeline->setSession($this->getWindowSession('timeline'));
|
$timeline->setSession($this->getWindowSession('timeline'));
|
||||||
|
|
|
@ -81,6 +81,13 @@ class TimeLine implements IteratorAggregate
|
||||||
*/
|
*/
|
||||||
protected $circleDiameter = 100.0;
|
protected $circleDiameter = 100.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum diameter each circle can have
|
||||||
|
*
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
protected $minCircleDiameter = 1.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unit of a circle's diameter
|
* The unit of a circle's diameter
|
||||||
*
|
*
|
||||||
|
@ -154,14 +161,35 @@ class TimeLine implements IteratorAggregate
|
||||||
public function setMaximumCircleWidth($width)
|
public function setMaximumCircleWidth($width)
|
||||||
{
|
{
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if (preg_match('#([\d]+)([a-z]+|%)#', $width, $matches)) {
|
if (preg_match('#([\d|\.]+)([a-z]+|%)#', $width, $matches)) {
|
||||||
$this->circleDiameter = intval($matches[1]);
|
$this->circleDiameter = floatval($matches[1]);
|
||||||
$this->diameterUnit = $matches[2];
|
$this->diameterUnit = $matches[2];
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Width "' . $width . '" is not a valid width');
|
throw new Exception('Width "' . $width . '" is not a valid width');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum diameter each circle can have
|
||||||
|
*
|
||||||
|
* @param string $width The diameter to set, suffixed with its unit
|
||||||
|
*
|
||||||
|
* @throws Exception If the given diameter is invalid or its unit differs from the maximum
|
||||||
|
*/
|
||||||
|
public function setMinimumCircleWidth($width)
|
||||||
|
{
|
||||||
|
$matches = array();
|
||||||
|
if (preg_match('#([\d|\.]+)([a-z]+|%)#', $width, $matches)) {
|
||||||
|
if ($matches[2] === $this->diameterUnit) {
|
||||||
|
$this->minCircleDiameter = floatval($matches[1]);
|
||||||
|
} else {
|
||||||
|
throw new Exception('Unit needs to be in "' . $this->diameterUnit . '"');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception('Width "' . $width . '" is not a valid width');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all known group types (identifiers) with their respective labels and colors as array
|
* Return all known group types (identifiers) with their respective labels and colors as array
|
||||||
*
|
*
|
||||||
|
@ -190,7 +218,12 @@ class TimeLine implements IteratorAggregate
|
||||||
{
|
{
|
||||||
$base = $this->getCalculationBase(true);
|
$base = $this->getCalculationBase(true);
|
||||||
$factor = log($group->getValue() * $group->getWeight(), $base) / 100;
|
$factor = log($group->getValue() * $group->getWeight(), $base) / 100;
|
||||||
return sprintf('%.' . $precision . 'F%s', $this->circleDiameter * $factor, $this->diameterUnit);
|
$width = $this->circleDiameter * $factor;
|
||||||
|
return sprintf(
|
||||||
|
'%.' . $precision . 'F%s',
|
||||||
|
$width > $this->minCircleDiameter ? $width : $this->minCircleDiameter,
|
||||||
|
$this->diameterUnit
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue