Display bigger legend labels correctly without overlapping

This commit is contained in:
Matthias Jentsch 2015-01-13 18:25:19 +01:00
parent 1732fa90e8
commit 76d3e5435f
1 changed files with 2 additions and 1 deletions

View File

@ -66,13 +66,14 @@ class Legend implements Drawable
$outer->getLayout()->setPadding(2, 2, 2, 2); $outer->getLayout()->setPadding(2, 2, 2, 2);
$nrOfColumns = 4; $nrOfColumns = 4;
$leftstep = 100 / $nrOfColumns;
$topstep = 10 / $nrOfColumns + 2; $topstep = 10 / $nrOfColumns + 2;
$top = 0; $top = 0;
$left = 0; $left = 0;
$lastLabelEndPos = -1; $lastLabelEndPos = -1;
foreach ($this->dataset as $color => $text) { foreach ($this->dataset as $color => $text) {
$leftstep = 100 / $nrOfColumns + strlen($text);
// Make sure labels don't overlap each other // Make sure labels don't overlap each other
while ($lastLabelEndPos >= $left) { while ($lastLabelEndPos >= $left) {
$left += $leftstep; $left += $leftstep;