Skip to content

Commit

Permalink
Fixed range calculation according to customAxisMin/Max (Related to #767)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Feb 22, 2016
1 parent d12cbcd commit 00d3e27
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,18 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar
_data.calcMinMax(start: lowestVisibleXIndex, end: highestVisibleXIndex)
}

var minLeft = _data.getYMin(.Left)
var maxLeft = _data.getYMax(.Left)
var minRight = _data.getYMin(.Right)
var maxRight = _data.getYMax(.Right)
var minLeft = !isnan(_leftAxis.customAxisMin)
? _leftAxis.customAxisMin
: _data.getYMin(.Left)
var maxLeft = !isnan(_leftAxis.customAxisMax)
? _leftAxis.customAxisMax
: _data.getYMax(.Left)
var minRight = !isnan(_rightAxis.customAxisMin)
? _rightAxis.customAxisMin
: _data.getYMin(.Right)
var maxRight = !isnan(_rightAxis.customAxisMax)
? _rightAxis.customAxisMax
: _data.getYMax(.Right)

let leftRange = abs(maxLeft - minLeft)
let rightRange = abs(maxRight - minRight)
Expand Down
16 changes: 12 additions & 4 deletions Charts/Classes/Charts/RadarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public class RadarChartView: PieRadarChartViewBase
{
super.calcMinMax()

let minLeft = _data.getYMin(.Left)
let maxLeft = _data.getYMax(.Left)
let minLeft = !isnan(_yAxis.customAxisMin)
? _yAxis.customAxisMin
: _data.getYMin(.Left)
let maxLeft = !isnan(_yAxis.customAxisMax)
? _yAxis.customAxisMax
: _data.getYMax(.Left)

_chartXMax = Double(_data.xVals.count) - 1.0
_deltaX = CGFloat(abs(_chartXMax - _chartXMin))
Expand All @@ -89,8 +93,12 @@ public class RadarChartView: PieRadarChartViewBase
let bottomSpaceLeft = Double(leftRange * _yAxis.spaceBottom)

// Use the values as they are
_yAxis.axisMinimum = !isnan(_yAxis.customAxisMin) ? _yAxis.customAxisMin : (minLeft - bottomSpaceLeft)
_yAxis.axisMaximum = !isnan(_yAxis.customAxisMax) ? _yAxis.customAxisMax : (maxLeft + topSpaceLeft)
_yAxis.axisMinimum = !isnan(_yAxis.customAxisMin)
? _yAxis.customAxisMin
: (minLeft - bottomSpaceLeft)
_yAxis.axisMaximum = !isnan(_yAxis.customAxisMax)
? _yAxis.customAxisMax
: (maxLeft + topSpaceLeft)

_chartXMax = Double(_data.xVals.count) - 1.0
_deltaX = CGFloat(abs(_chartXMax - _chartXMin))
Expand Down

0 comments on commit 00d3e27

Please sign in to comment.