Skip to content

Commit

Permalink
Do not add extra spacing after last legend element
Browse files Browse the repository at this point in the history
This affected mainly RTL legend, but occasionally cause more spacing than the xOffset set for the legend even for LTR.
  • Loading branch information
danielgindi committed Mar 24, 2015
1 parent 377bc09 commit 2b908e0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Charts/Classes/Components/ChartLegend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class ChartLegend: ChartComponentBase
var width = CGFloat(0.0);
var height = CGFloat(0.0);

for (var i = 0; i < _labels.count; i++)
for (var i = 0, count = _labels.count; i < count; i++)
{
if (labels[i] != nil)
{
Expand All @@ -188,14 +188,22 @@ public class ChartLegend: ChartComponentBase
var size = (_labels[i] as NSString!).sizeWithAttributes([NSFontAttributeName: labelFont]);

width += size.width;
width += xEntrySpace;

height += size.height;
height += yEntrySpace;

if (i < count - 1)
{
width += xEntrySpace;
height += yEntrySpace;
}
}
else
{
width += formSize + stackSpace;

if (i < count - 1)
{
width += stackSpace;
}
}
}

Expand Down

0 comments on commit 2b908e0

Please sign in to comment.