Skip to content

Commit

Permalink
Adjust brightness for different event type colors
Browse files Browse the repository at this point in the history
  • Loading branch information
majentsch committed Sep 19, 2014
1 parent 65203fd commit 6f1cb6f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions library/Icinga/Web/Widget/Chart/HistoryColorGrid.php
Expand Up @@ -29,10 +29,9 @@ class HistoryColorGrid extends AbstractWidget {

private $start = null;
private $end = null;

private $data = array();

private $color;
public $opacity = 1.0;

public function __construct($color = '#51e551', $start = null, $end = null) {
$this->setColor($color);
Expand Down Expand Up @@ -90,6 +89,16 @@ public function setColor($color)
$this->color = $color;
}

/**
* Set the used opacity
*
* @param $opacity
*/
public function setOpacity($opacity)
{
$this->opacity = $opacity;
}

/**
* Calculate the color to display for the given value.
*
Expand All @@ -115,13 +124,14 @@ private function renderDay($day)
if (array_key_exists($day, $this->data)) {
$entry = $this->data[$day];
return'<a ' .
'style="background-color:' . $this->calculateColor($entry['value']) . ';" ' .
'style="background-color:' . $this->calculateColor($entry['value']) . '; '
. ' opacity: ' . $this->opacity . ';"' .
'title="' . $entry['caption'] . '" ' .
'href="' . $entry['url'] . '"' .
'>&nbsp;</a>';
} else {
return '<a ' .
'style="background-color:' . $this->calculateColor(0) . ';" ' .
'style="background-color:' . $this->calculateColor(0) . '; ' . ' opacity: ' . $this->opacity . ';' .
'title="No entries for ' . $day . '" ' .
'></a>';
}
Expand Down

0 comments on commit 6f1cb6f

Please sign in to comment.