Constructor can be told to not set default colors.

This commit is contained in:
Andrew Tomaka 2011-10-27 10:33:53 -04:00
parent 5c7dd6ba7f
commit b36c90d35d

View file

@ -40,7 +40,8 @@ class Gantt {
private $colors = array(); private $colors = array();
/** /**
* Track the number of times we've retrieved colors * Track the number of times we've retrieved colors so that we
* can always return alternating colors.
* @access private * @access private
* @var integer * @var integer
**/ **/
@ -49,10 +50,12 @@ class Gantt {
/** /**
* Constructor * Constructor
**/ **/
function __construct() { function __construct($colors = true) {
//add a default set of colors //add a default set of colors
if($colors) {
$this->add_color('#FF8080','#99CCFF','#00FF00','#FF9900','#800080'); $this->add_color('#FF8080','#99CCFF','#00FF00','#FF9900','#800080');
} }
}
/** /**
* Add an event to be processed * Add an event to be processed
@ -90,6 +93,12 @@ class Gantt {
if($this->html != '') { if($this->html != '') {
return $this->html; return $this->html;
} }
//require that there is at least one color set.
if(count($this->colors) == 0) {
return 'Error! At least one colors must be set: add_colors("#000")';
}
$columns = $this->find_last(); $columns = $this->find_last();
// probably should template this html sometime. // probably should template this html sometime.