Skip to content

Commit

Permalink
Fixed the avoidFirstLastClipping feature (Fixes #479)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 23, 2015
1 parent 4ae557c commit 0ad97f3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ public class ChartXAxisRendererBarChart: ChartXAxisRenderer
{
let width = label!.sizeWithAttributes(labelAttrs).width

if (width > viewPortHandler.offsetRight * 2.0
&& position.x + width > viewPortHandler.chartWidth)
if (position.x + width / 2.0 > viewPortHandler.contentRight)
{
position.x -= width / 2.0
position.x = viewPortHandler.contentRight - (width / 2.0)
}
}
else if (i == 0)
{ // avoid clipping of the first
let width = label!.sizeWithAttributes(labelAttrs).width
position.x += width / 2.0

if (position.x - width / 2.0 < viewPortHandler.contentLeft)
{
position.x = viewPortHandler.contentLeft + (width / 2.0)
}
}
}

Expand Down

0 comments on commit 0ad97f3

Please sign in to comment.