Skip to content

Commit

Permalink
Merge pull request #1389 from liuxuan30/V3-Swift2.3
Browse files Browse the repository at this point in the history
migrate Chart v3 code in master to swift 2.3 branch
  • Loading branch information
liuxuan30 authored Sep 1, 2016
2 parents 2b58abe + 5a1a7ce commit ee51dba
Show file tree
Hide file tree
Showing 429 changed files with 50,602 additions and 36,716 deletions.
2 changes: 1 addition & 1 deletion Charts.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Pod::Spec.new do |s|
s.subspec "Realm" do |ss|
ss.source_files = "ChartsRealm/Classes/**/*.swift"
ss.dependency "Charts/Core"
ss.dependency "RealmSwift", "~> 0.97"
ss.dependency "RealmSwift", "~> 1.0.2"
end
end
2 changes: 1 addition & 1 deletion Charts/Cartfile.private
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "facebook/ios-snapshot-test-case" ~> 2.1
github "facebook/ios-snapshot-test-case" ~> 2.1.2
2 changes: 1 addition & 1 deletion Charts/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "facebook/ios-snapshot-test-case" "2.1.1"
github "facebook/ios-snapshot-test-case" "2.1.2"
768 changes: 464 additions & 304 deletions Charts/Charts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
15 changes: 8 additions & 7 deletions Charts/ChartsTests/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ class BarChartTests: FBSnapshotTestCase
99, 14, 84, 48, 40, 71, 106, 41, 45, 61]

var entries: [ChartDataEntry] = Array()
var xValues: [String] = Array()

for (i, value) in values.enumerate()
{
entries.append(BarChartDataEntry.init(value: value, xIndex: i))
xValues.append("\(i)")
entries.append(BarChartDataEntry(x: Double(i), y: value))
}

dataSet = BarChartDataSet(yVals: entries, label: "Bar chart unit test data")
dataSet = BarChartDataSet(values: entries, label: "Bar chart unit test data")

let data = BarChartData(dataSet: dataSet)
data.barWidth = 0.85;

chart = BarChartView(frame: CGRectMake(0, 0, 480, 350))
chart.leftAxis.axisMinValue = 0.0
chart.rightAxis.axisMinValue = 0.0
chart.data = BarChartData(xVals: xValues, dataSet: dataSet)
chart.leftAxis.axisMinimum = 0.0
chart.rightAxis.axisMinimum = 0.0
chart.data = data
}

override func tearDown()
Expand Down
12 changes: 5 additions & 7 deletions Charts/ChartsTests/LineChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@ class LineChartTests: FBSnapshotTestCase
99, 14, 84, 48, 40, 71, 106, 41, 45, 61]

var entries: [ChartDataEntry] = Array()
var xValues: [String] = Array()

for (i, value) in values.enumerate()
{
entries.append(ChartDataEntry.init(value: value, xIndex: i))
xValues.append("\(i)")
entries.append(ChartDataEntry(x: Double(i), y: value))
}

dataSet = LineChartDataSet(yVals: entries, label: "First unit test data")
dataSet = LineChartDataSet(values: entries, label: "First unit test data")

chart = LineChartView(frame: CGRectMake(0, 0, 480, 350))
chart.leftAxis.axisMinValue = 0.0
chart.rightAxis.axisMinValue = 0.0
chart.data = LineChartData(xVals: xValues, dataSet: dataSet)
chart.leftAxis.axisMinimum = 0.0
chart.rightAxis.axisMinimum = 0.0
chart.data = LineChartData(dataSet: dataSet)
}

override func tearDown()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//
// ChartAnimator.swift
// Animator.swift
// Charts
//
// Created by Daniel Cohen Gindi on 3/3/15.
//
// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
// A port of MPAndroidChart for iOS
// Licensed under Apache License 2.0
Expand All @@ -18,31 +16,32 @@ import CoreGraphics
import UIKit
#endif

@objc
public protocol ChartAnimatorDelegate
@objc(ChartAnimatorDelegate)
public protocol AnimatorDelegate
{
/// Called when the Animator has stepped.
func chartAnimatorUpdated(chartAnimator: ChartAnimator)
func animatorUpdated(chartAnimator: Animator)

/// Called when the Animator has stopped.
func chartAnimatorStopped(chartAnimator: ChartAnimator)
func animatorStopped(chartAnimator: Animator)
}

public class ChartAnimator: NSObject
@objc(ChartAnimator)
public class Animator: NSObject
{
public weak var delegate: ChartAnimatorDelegate?
public weak var delegate: AnimatorDelegate?
public var updateBlock: (() -> Void)?
public var stopBlock: (() -> Void)?

/// the phase that is animated and influences the drawn values on the x-axis
public var phaseX: CGFloat = 1.0
public var phaseX: Double = 1.0

/// the phase that is animated and influences the drawn values on the y-axis
public var phaseY: CGFloat = 1.0
public var phaseY: Double = 1.0

private var _startTimeX: NSTimeInterval = 0.0
private var _startTimeY: NSTimeInterval = 0.0
private var _displayLink: NSUIDisplayLink!
private var _displayLink: NSUIDisplayLink?

private var _durationX: NSTimeInterval = 0.0
private var _durationY: NSTimeInterval = 0.0
Expand All @@ -69,9 +68,9 @@ public class ChartAnimator: NSObject

public func stop()
{
if (_displayLink != nil)
if _displayLink != nil
{
_displayLink.removeFromRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink?.removeFromRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink = nil

_enabledX = false
Expand All @@ -85,7 +84,7 @@ public class ChartAnimator: NSObject

if (delegate != nil)
{
delegate!.chartAnimatorUpdated(self)
delegate!.animatorUpdated(self)
}
if (updateBlock != nil)
{
Expand All @@ -95,7 +94,7 @@ public class ChartAnimator: NSObject

if (delegate != nil)
{
delegate!.chartAnimatorStopped(self)
delegate!.animatorStopped(self)
}
if (stopBlock != nil)
{
Expand All @@ -122,7 +121,7 @@ public class ChartAnimator: NSObject
}
else
{
phaseX = CGFloat(elapsed / duration)
phaseX = Double(elapsed / duration)
}
}
if (_enabledY)
Expand All @@ -141,7 +140,7 @@ public class ChartAnimator: NSObject
}
else
{
phaseY = CGFloat(elapsed / duration)
phaseY = Double(elapsed / duration)
}
}
}
Expand All @@ -154,7 +153,7 @@ public class ChartAnimator: NSObject

if (delegate != nil)
{
delegate!.chartAnimatorUpdated(self)
delegate!.animatorUpdated(self)
}
if (updateBlock != nil)
{
Expand Down Expand Up @@ -193,10 +192,10 @@ public class ChartAnimator: NSObject
// Take care of the first frame if rendering is already scheduled...
updateAnimationPhases(_startTimeX)

if (_enabledX || _enabledY)
if _enabledX || _enabledY
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(ChartAnimator.animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}

Expand Down Expand Up @@ -259,10 +258,10 @@ public class ChartAnimator: NSObject

if (_enabledX || _enabledY)
{
if _displayLink === nil
if _displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(ChartAnimator.animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}
}
Expand Down Expand Up @@ -303,10 +302,10 @@ public class ChartAnimator: NSObject

if (_enabledX || _enabledY)
{
if _displayLink === nil
if _displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(ChartAnimator.animationLoop))
_displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
}
}
}
Expand Down
Loading

0 comments on commit ee51dba

Please sign in to comment.