Skip to content

Commit

Permalink
Make getBarBounds callable from Objective-C code (Fixes #570)
Browse files Browse the repository at this point in the history
Changed method return value to nonnull, because CGRect in Objective-C doesn't allow nil since it's not an object. When the bar bounds cannot be calculated because the data set is nil now the method returns CGRectNull instead of nil.
  • Loading branch information
albertdonaire committed Nov 25, 2015
1 parent a942a4a commit 8cf8d1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Charts/Classes/Charts/BarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ public class BarChartView: BarLineChartViewBase, BarChartDataProvider
}

/// - returns: the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be found in the charts data.
public func getBarBounds(e: BarChartDataEntry) -> CGRect!
public func getBarBounds(e: BarChartDataEntry) -> CGRect
{
let set = _data.getDataSetForEntry(e) as! BarChartDataSet!

if (set === nil)
{
return nil
return CGRectNull
}

let barspace = set.barSpace
Expand Down
6 changes: 3 additions & 3 deletions Charts/Classes/Charts/HorizontalBarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public class HorizontalBarChartView: BarChartView
}
}

public override func getBarBounds(e: BarChartDataEntry) -> CGRect!
public override func getBarBounds(e: BarChartDataEntry) -> CGRect
{
let set = _data.getDataSetForEntry(e) as! BarChartDataSet!

if (set === nil)
{
return nil
return CGRectNull
}

let barspace = set.barSpace
Expand Down Expand Up @@ -205,4 +205,4 @@ public class HorizontalBarChartView: BarChartView

return Int((pt.y >= CGFloat(chartXMax)) ? CGFloat(chartXMax) / div : (pt.y / div))
}
}
}

0 comments on commit 8cf8d1a

Please sign in to comment.