diff --git a/graph.php b/graph.php index 50eedcd..1cfc561 100644 --- a/graph.php +++ b/graph.php @@ -174,7 +174,7 @@ class graph /** Draw the graph to the screen with the previous defined parameters */ - public function drawImage () + private function drawReal () { // Read the data $series = $this->data->getSeries (); @@ -318,6 +318,11 @@ class graph // Add the legend on right $free = $this->legend->draw ($gd, $free, $this->series); + // If there is no title, add an offset of 10px to display correctely the + // first label of the Y axis + if ($free[1] === 0) + $free[1] = 10; + // Add the axis // Need two passes as the X axis can modify the Y axes $this->axisX->top ($free[1]); @@ -356,18 +361,25 @@ class graph $this->axisX, $this->axisY2); } $free = $lastFree; - header ('Content-Type: image/png'); imagepng ($gd); imagedestroy ($gd); } + /** Draw the graph to the screen with the previous defined parameters + */ + public function drawImage () + { + header ('Content-Type: image/png'); + $this->drawReal (); + } + /** Return the image coded in base64 * @return string The base64 string */ public function drawBase64 () { ob_start (); - $this->drawImage (); + $this->drawReal (); return base64_encode (ob_get_clean()); } } @@ -615,7 +627,7 @@ class graphSerie return $this->style; } if (! is_string ($style) || - ! in_array ($style, array ("line"))) + ! in_array ($style, array ("line", "points", "linePoints"))) throw new \Exception (dgettext ("domframework", "Invalid style provided to serie"), 406); $styleClass = "graphStyle".$style;