Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AlBirdie/ios-charts into …
Browse files Browse the repository at this point in the history
…AlBirdie-master
  • Loading branch information
danielgindi committed May 27, 2015
2 parents 5a9190e + 0b76972 commit bee7b6c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,33 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
/// returns true if auto scaling on the y axis is enabled.
/// :default: false
public var isAutoScaleMinMaxEnabled : Bool { return autoScaleMinMaxEnabled; }


/// Sets a custom width to the specified y axis.
public func setXAxisWidth(which: ChartYAxis.AxisDependency, width: CGFloat)
{
if (which == .Left)
{
_leftAxis.setCustomWidth(width);
}
else
{
_rightAxis.setCustomWidth(width);
}
}

/// Returns the width of the specified y axis.
public func getXAxisWidth(which: ChartYAxis.AxisDependency) -> CGFloat
{
if (which == .Left)
{
return _leftAxis.requiredSize().width;
}
else
{
return _rightAxis.requiredSize().width;
}
}
}

/// Default formatter that calculates the position of the filled line.
Expand Down
10 changes: 10 additions & 0 deletions Charts/Classes/Components/ChartYAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public class ChartYAxis: ChartAxisBase
/// the side this axis object represents
private var _axisDependency = AxisDependency.Left

/// the width the axis should take
private var _customWidth = CGFloat(0);

public override init()
{
super.init();
Expand Down Expand Up @@ -158,6 +161,7 @@ public class ChartYAxis: ChartAxisBase
var size = label.sizeWithAttributes([NSFontAttributeName: labelFont]);
size.width += xOffset * 2.0;
size.height += yOffset * 2.0;
size.width = max(_customWidth, size.width);
return size;
}

Expand Down Expand Up @@ -202,6 +206,12 @@ public class ChartYAxis: ChartAxisBase
}
}

/// Sets a custom width to the axis that can be bigger than the requried size of the longest label. Note: narrower axis widths are not supported.
public func setCustomWidth(width: CGFloat)
{
_customWidth = width;
}

public var isInverted: Bool { return inverted; }

public var isStartAtZeroEnabled: Bool { return startAtZeroEnabled; }
Expand Down

0 comments on commit bee7b6c

Please sign in to comment.