/** * Predisplay function * * @return void */ function prepare() { $values = $this->_values; $count = count($values); $max = max(max($values), 10); $min = min($values); $normalized = array(); for ($i = 0; $i < $count; $i++) { if ($max == 0) { $normalized[$i] = $this->_height; } else { $normalized[$i] = $this->_height - $values[$i] / $max * $this->_height; } } $div = $this->_width / ($count - 1); for ($i = 0; $i < $count - 1; $i++) { $s = new GSegment(); $s->setCoordinates($i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1]); $s->setSize($this->getSize()); $s->setColor($this->_r_color, $this->_g_color, $this->_b_color); $this->addElement($s); if ($this->_show_background) { $values = array($i * $div, $this->_height, $i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1], ($i + 1) * $div, $this->_height); $p = new GPolygon($values); $p->setColor($this->_background_r_color, $this->_background_g_color, $this->_background_b_color); $this->addElement($p); } if ($this->_show_values && $i % 3 == 0) { $str = new GString("" . $this->_values[$i]); $str->setCoordinates($i * $div, $normalized[$i], ($i + 1) * $div, $normalized[$i + 1]); $str->setDistance(18); $this->addElement($str); } } $str = new GString("" . $this->_values[$count - 1]); $str->setCoordinates(($count - 1) * $div, $normalized[$count - 1]); $str->setDistance(18); $this->addElement($str); }