Skip to content

Commit

Permalink
Inverted axis mode taken care of in stacked bars
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Jul 17, 2015
1 parent bd89f68 commit 8d2106b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions Charts/Classes/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,17 @@ public class BarChartRenderer: ChartDataRendererBase

var left = x - barWidth + barSpaceHalf
var right = x + barWidth - barSpaceHalf
var top = y >= yStart ? CGFloat(y) : CGFloat(yStart)
var bottom = y <= yStart ? CGFloat(y) : CGFloat(yStart)
var top: CGFloat, bottom: CGFloat
if isInverted
{
bottom = y >= yStart ? CGFloat(y) : CGFloat(yStart)
top = y <= yStart ? CGFloat(y) : CGFloat(yStart)
}
else
{
top = y >= yStart ? CGFloat(y) : CGFloat(yStart)
bottom = y <= yStart ? CGFloat(y) : CGFloat(yStart)
}

// multiply the height of the rect with the phase
top *= phaseY
Expand Down
13 changes: 11 additions & 2 deletions Charts/Classes/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,17 @@ public class HorizontalBarChartRenderer: BarChartRenderer

var bottom = x - barWidth + barSpaceHalf
var top = x + barWidth - barSpaceHalf
var right = y >= yStart ? CGFloat(y) : CGFloat(yStart)
var left = y <= yStart ? CGFloat(y) : CGFloat(yStart)
var right: CGFloat, left: CGFloat
if isInverted
{
left = y >= yStart ? CGFloat(y) : CGFloat(yStart)
right = y <= yStart ? CGFloat(y) : CGFloat(yStart)
}
else
{
right = y >= yStart ? CGFloat(y) : CGFloat(yStart)
left = y <= yStart ? CGFloat(y) : CGFloat(yStart)
}

// multiply the height of the rect with the phase
right *= phaseY
Expand Down

0 comments on commit 8d2106b

Please sign in to comment.