Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ChartsDemo/ChartsDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@
5B57BBAE1A9B26AA0036A6CC = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -850,7 +851,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -869,7 +870,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -896,7 +897,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -908,7 +909,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -924,6 +925,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(SOURCE_ROOT)/../Carthage/Build/iOS";
INFOPLIST_FILE = "Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -944,6 +946,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = "$(SOURCE_ROOT)/../Carthage/Build/iOS";
INFOPLIST_FILE = "Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
20 changes: 10 additions & 10 deletions Source/Charts/Animation/ChartAnimationEasing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ internal struct EasingFunctions

internal static let EaseInSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
var position: TimeInterval = elapsed / duration
return Double( -cos(position * M_PI_2) + 1.0 )
return Double( -cos(position * .pi/2) + 1.0 )
}

internal static let EaseOutSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
var position: TimeInterval = elapsed / duration
return Double( sin(position * M_PI_2) )
return Double( sin(position * .pi/2) )
}

internal static let EaseInOutSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
var position: TimeInterval = elapsed / duration
return Double( -0.5 * (cos(M_PI * position) - 1.0) )
return Double( -0.5 * (cos(.pi * position) - 1.0) )
}

internal static let EaseInExpo = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand Down Expand Up @@ -286,9 +286,9 @@ internal struct EasingFunctions
}

var p = duration * 0.3
var s = p / (2.0 * M_PI) * asin(1.0)
var s = p / (2.0 * .pi) * asin(1.0)
position -= 1.0
return Double( -(pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p)) )
return Double( -(pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * .pi) / p)) )
}

internal static let EaseOutElastic = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand All @@ -304,8 +304,8 @@ internal struct EasingFunctions
}

var p = duration * 0.3
var s = p / (2.0 * M_PI) * asin(1.0)
return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p) + 1.0 )
var s = p / (2.0 * .pi) * asin(1.0)
return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * .pi) / p) + 1.0 )
}

internal static let EaseInOutElastic = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand All @@ -321,14 +321,14 @@ internal struct EasingFunctions
}

var p = duration * (0.3 * 1.5)
var s = p / (2.0 * M_PI) * asin(1.0)
var s = p / (2.0 * .pi) * asin(1.0)
if position < 1.0
{
position -= 1.0
return Double( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p)) )
return Double( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * .pi) / p)) )
}
position -= 1.0
return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p) * 0.5 + 1.0 )
return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * .pi) / p) * 0.5 + 1.0 )
}

internal static let EaseInBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
Expand Down
56 changes: 39 additions & 17 deletions Source/Charts/Components/AxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,52 @@ open class AxisBase: ComponentBase
open var gridLineCap = CGLineCap.butt

open var drawGridLinesEnabled = true
open var drawAxisLineEnabled = true
open var drawAxisLineEnabled = true

open var logarithmicEnabled = false
open var isLogarithmicEnabled: Bool { return logarithmicEnabled }

open var maskAxis = [1.0, 2.0, 4.0, 6.0, 8.0]
open var maskLabels = [true, true, true, true, true]

open var logAxis = [Double]()
open var logLabels = [Bool]()

open var labelsAxisChanged = true
open var isLabelsAxisChanged: Bool { return labelsAxisChanged }

open var stickEnabled = false
open var isStickEnabled: Bool { return stickEnabled }

open var stickMajorEnabled = true
open var isStickMajorEnabled: Bool { return stickMajorEnabled }

/// flag that indicates of the labels of this axis should be drawn or not
open var drawLabelsEnabled = true

fileprivate var _centerAxisLabelsEnabled = false

/// Centers the axis labels instead of drawing them at their original position.
/// This is useful especially for grouped BarChart.
open var centerAxisLabelsEnabled: Bool
{
{
get { return _centerAxisLabelsEnabled && entryCount > 0 }
set { _centerAxisLabelsEnabled = newValue }
}

open var isCenterAxisLabelsEnabled: Bool
{
{
get { return centerAxisLabelsEnabled }
}

/// array of limitlines that can be set for the axis
fileprivate var _limitLines = [ChartLimitLine]()

/// Are the LimitLines drawn behind the data or in front of the data?
///
///
/// **default**: false
open var drawLimitLinesBehindDataEnabled = false

/// the flag can be used to turn off the antialias for grid lines
open var gridAntialiasEnabled = true

Expand Down Expand Up @@ -100,7 +118,7 @@ open class AxisBase: ComponentBase
///
/// **default**: 1.0
open var granularity: Double
{
{
get
{
return _granularity
Expand All @@ -116,7 +134,7 @@ open class AxisBase: ComponentBase

/// The minimum interval between axis values.
open var isGranularityEnabled: Bool
{
{
get
{
return granularityEnabled
Expand Down Expand Up @@ -150,6 +168,10 @@ open class AxisBase: ComponentBase
{
return ""
}
if isLogarithmicEnabled == true
{
return valueFormatter?.stringForValue(pow(10, entries[index]), axis: self) ?? ""
}

return valueFormatter?.stringForValue(entries[index], axis: self) ?? ""
}
Expand All @@ -158,7 +180,7 @@ open class AxisBase: ComponentBase
/// If no formatter is set, the chart will automatically determine a reasonable formatting (concerning decimals) for all the values that are drawn inside the chart.
/// Use `nil` to use the formatter calculated by the chart.
open var valueFormatter: IAxisValueFormatter?
{
{
get
{
if _axisValueFormatter == nil ||
Expand All @@ -184,7 +206,7 @@ open class AxisBase: ComponentBase
open var isDrawLabelsEnabled: Bool { return drawLabelsEnabled }

/// Are the LimitLines drawn behind the data or in front of the data?
///
///
/// **default**: false
open var isDrawLimitLinesBehindDataEnabled: Bool { return drawLimitLinesBehindDataEnabled }

Expand Down Expand Up @@ -219,7 +241,7 @@ open class AxisBase: ComponentBase
/// default = 6,
/// be aware that this number is not fixed and can only be approximated
open var labelCount: Int
{
{
get
{
return _labelCount
Expand All @@ -230,7 +252,7 @@ open class AxisBase: ComponentBase

if _labelCount > 25
{
_labelCount = 25
_labelCount = 50
}
if _labelCount < 2
{
Expand Down Expand Up @@ -302,15 +324,15 @@ open class AxisBase: ComponentBase
/// This property is deprecated - Use `axisMinimum` instead.
@available(*, deprecated: 1.0, message: "Use axisMinimum instead.")
open var axisMinValue: Double
{
{
get { return axisMinimum }
set { axisMinimum = newValue }
}

/// This property is deprecated - Use `axisMaximum` instead.
@available(*, deprecated: 1.0, message: "Use axisMaximum instead.")
open var axisMaxValue: Double
{
{
get { return axisMaximum }
set { axisMaximum = newValue }
}
Expand All @@ -319,7 +341,7 @@ open class AxisBase: ComponentBase
/// If set, this value will not be calculated automatically depending on the provided data.
/// Use `resetCustomAxisMin()` to undo this.
open var axisMinimum: Double
{
{
get
{
return _axisMinimum
Expand All @@ -336,7 +358,7 @@ open class AxisBase: ComponentBase
/// If set, this value will not be calculated automatically depending on the provided data.
/// Use `resetCustomAxisMax()` to undo this.
open var axisMaximum: Double
{
{
get
{
return _axisMaximum
Expand Down
40 changes: 20 additions & 20 deletions Source/Charts/Data/Implementations/Standard/ChartData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import Foundation

open class ChartData: NSObject
{
internal var _yMax: Double = -DBL_MAX
internal var _yMin: Double = DBL_MAX
internal var _xMax: Double = -DBL_MAX
internal var _xMin: Double = DBL_MAX
internal var _leftAxisMax: Double = -DBL_MAX
internal var _leftAxisMin: Double = DBL_MAX
internal var _rightAxisMax: Double = -DBL_MAX
internal var _rightAxisMin: Double = DBL_MAX
internal var _yMax: Double = -.greatestFiniteMagnitude
internal var _yMin: Double = .greatestFiniteMagnitude
internal var _xMax: Double = -.greatestFiniteMagnitude
internal var _xMin: Double = .greatestFiniteMagnitude
internal var _leftAxisMax: Double = -.greatestFiniteMagnitude
internal var _leftAxisMin: Double = .greatestFiniteMagnitude
internal var _rightAxisMax: Double = -.greatestFiniteMagnitude
internal var _rightAxisMin: Double = .greatestFiniteMagnitude

internal var _dataSets = [IChartDataSet]()

Expand Down Expand Up @@ -71,20 +71,20 @@ open class ChartData: NSObject
/// calc minimum and maximum y value over all datasets
open func calcMinMax()
{
_yMax = -DBL_MAX
_yMin = DBL_MAX
_xMax = -DBL_MAX
_xMin = DBL_MAX
_yMax = -.greatestFiniteMagnitude
_yMin = .greatestFiniteMagnitude
_xMax = -.greatestFiniteMagnitude
_xMin = .greatestFiniteMagnitude

for set in _dataSets
{
calcMinMax(dataSet: set)
}

_leftAxisMax = -DBL_MAX
_leftAxisMin = DBL_MAX
_rightAxisMax = -DBL_MAX
_rightAxisMin = DBL_MAX
_leftAxisMax = -.greatestFiniteMagnitude
_leftAxisMin = .greatestFiniteMagnitude
_rightAxisMax = -.greatestFiniteMagnitude
_rightAxisMin = .greatestFiniteMagnitude

// left axis
let firstLeft = getFirstLeft(dataSets: dataSets)
Expand Down Expand Up @@ -257,7 +257,7 @@ open class ChartData: NSObject
{
if axis == .left
{
if _leftAxisMin == DBL_MAX
if _leftAxisMin == .greatestFiniteMagnitude
{
return _rightAxisMin
}
Expand All @@ -268,7 +268,7 @@ open class ChartData: NSObject
}
else
{
if _rightAxisMin == DBL_MAX
if _rightAxisMin == .greatestFiniteMagnitude
{
return _leftAxisMin
}
Expand All @@ -295,7 +295,7 @@ open class ChartData: NSObject
{
if axis == .left
{
if _leftAxisMax == -DBL_MAX
if _leftAxisMax == -.greatestFiniteMagnitude
{
return _rightAxisMax
}
Expand All @@ -306,7 +306,7 @@ open class ChartData: NSObject
}
else
{
if _rightAxisMax == -DBL_MAX
if _rightAxisMax == -.greatestFiniteMagnitude
{
return _leftAxisMax
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ open class ChartDataEntry: ChartDataEntryBase
return false
}

if fabs((object! as AnyObject).x - x) > DBL_EPSILON
if fabs((object! as AnyObject).x - x) > Double.ulpOfOne
{
return false
}
Expand Down Expand Up @@ -125,12 +125,12 @@ public func ==(lhs: ChartDataEntry, rhs: ChartDataEntry) -> Bool
return false
}

if fabs(lhs.x - rhs.x) > DBL_EPSILON
if fabs(lhs.x - rhs.x) > Double.ulpOfOne
{
return false
}

if fabs(lhs.y - rhs.y) > DBL_EPSILON
if fabs(lhs.y - rhs.y) > Double.ulpOfOne
{
return false
}
Expand Down
Loading