diff --git a/CHANGES.txt b/CHANGES.txt index c8ede98..4d36c1c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,10 +1,11 @@ -Version 2.19 +Version 2.19 (17/07/2015) ------------ - Added histogram. - Added shading overlay for 3D bar sides and top. - Added best_fit_opacity and best_fit_above options. - Added semantic class for best fit lines. - Added tooltip and data label callback options. +- Added data_label_min_space option. Version 2.18 (03/04/2015) ------------ diff --git a/SVGGraphBarGraph.php b/SVGGraphBarGraph.php index fd556d6..f5e0f33 100644 --- a/SVGGraphBarGraph.php +++ b/SVGGraphBarGraph.php @@ -40,7 +40,7 @@ protected function Draw() $body = $this->Grid() . $this->Guidelines(SVGG_GUIDELINE_BELOW); $bnum = 0; $bar_width = $this->BarWidth(); - $bspace = max(0, ($this->x_axes[$this->main_x_axis]->Unit() - $bar_width) / 2); + $bspace = $this->BarSpace($bar_width); $this->ColourSetup($this->values->ItemsCount()); $bars = ''; @@ -95,6 +95,14 @@ protected function BarWidth() return $this->bar_space >= $unit_w ? '1' : $unit_w - $this->bar_space; } + /** + * Returns the space before a bar + */ + protected function BarSpace($bar_width) + { + return max(0, ($this->x_axes[$this->main_x_axis]->Unit() - $bar_width) / 2); + } + /** * Fills in the y-position and height of a bar * @param number $value bar value diff --git a/SVGGraphHistogram.php b/SVGGraphHistogram.php index cb4c506..3b4afbc 100644 --- a/SVGGraphHistogram.php +++ b/SVGGraphHistogram.php @@ -158,8 +158,17 @@ protected function BarWidth() { if(is_numeric($this->bar_width) && $this->bar_width >= 1) return $this->bar_width; - $unit_w = $this->x_axes[$this->main_x_axis]->Unit(); - return $unit_w * $this->increment; + $unit_w = $this->increment * $this->x_axes[$this->main_x_axis]->Unit(); + return $this->bar_space >= $unit_w ? '1' : $unit_w - $this->bar_space; + } + + /** + * Returns the space before a bar + */ + protected function BarSpace($bar_width) + { + $uwidth = $this->increment * $this->x_axes[$this->main_x_axis]->Unit(); + return max(0, ($uwidth - $bar_width) / 2); } }