Adjust brightness for different event type colors

This commit is contained in:
Matthias Jentsch 2014-09-16 16:00:01 +02:00
parent 65203fddcf
commit 6f1cb6f1f3
1 changed files with 14 additions and 4 deletions

View File

@ -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);
@ -90,6 +89,16 @@ class HistoryColorGrid extends AbstractWidget {
$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.
*
@ -115,13 +124,14 @@ class HistoryColorGrid extends AbstractWidget {
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>';
}