Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test branch #868

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4b9cdd6
Merge remote-tracking branch 'danielgindi/master'
StephanieB5 Jan 11, 2016
df2f6af
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Jan 12, 2016
880e332
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 16, 2016
ae6d725
Adding a new chart in iOS demo app
StephanieB5 Mar 16, 2016
c1b3c17
Merge remote-tracking branch 'danielgindi/master'
StephanieB5 Mar 16, 2016
f89fe2d
Code sign identity and customizing controller
StephanieB5 Mar 16, 2016
f573e55
Adding pipeline for numeric data for the X axis
StephanieB5 Mar 17, 2016
1ce9765
Removing obsolete comment
StephanieB5 Mar 17, 2016
ed9bc08
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 17, 2016
b0d7f2a
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 17, 2016
2c09b2c
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 17, 2016
37057d2
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 17, 2016
8647d7e
Merge remote-tracking branch 'danielgindi/master' into test-branch
StephanieB5 Mar 18, 2016
978501a
Merge branch 'danielgindi/master'
StephanieB5 Mar 18, 2016
19ace8c
Move support for xNumericVal to the ChartData classes
StephanieB5 Mar 18, 2016
251a308
Merge branch 'danielgindi/master' into test-branch
StephanieB5 Mar 18, 2016
ba5aa07
Adding max and min for xNumericVal
StephanieB5 Mar 18, 2016
37dafd7
Add util for testing equality for Doubles
StephanieB5 Mar 20, 2016
eff73c6
Merge branch 'danielgindi/master' into test-branch
StephanieB5 Mar 20, 2016
6fc68d4
Initialize `drawZeroLineEnabled` to `false`, for backwards compatibil…
danielgindi Mar 18, 2016
b682ff5
Updated tests for `drawZeroLineEnabled=false` by default
danielgindi Mar 18, 2016
087c885
I missed some tests
danielgindi Mar 18, 2016
4f69bd8
Add Gitter badge
gitter-badger Mar 20, 2016
dca689b
Add new TimeLine chart type
StephanieB5 Mar 16, 2016
6d4b92b
Update README.md
danielgindi Mar 20, 2016
f3e7433
Adding back a comment that I removed by mistake
StephanieB5 Mar 22, 2016
eb57d40
Merge branch 'test-branch' of https://github.com/StephanieB5/ios-char…
StephanieB5 Mar 22, 2016
e58fc62
Add new TimeLine chart type (Issue #194)
StephanieB5 Mar 16, 2016
0cdfab0
Merge branch 'test-branch' of https://github.com/StephanieB5/ios-char…
StephanieB5 Mar 22, 2016
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
8 changes: 8 additions & 0 deletions Charts/Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
65F06FAE1BE826010074498D /* IPieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F06FAC1BE826010074498D /* IPieChartDataSet.swift */; };
65F06FB01BE826090074498D /* IRadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F06FAF1BE826090074498D /* IRadarChartDataSet.swift */; };
65F06FB11BE826090074498D /* IRadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F06FAF1BE826090074498D /* IRadarChartDataSet.swift */; };
909437471CA0CBC000BAFA36 /* TimeLineChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909437461CA0CBC000BAFA36 /* TimeLineChartView.swift */; };
9094374B1CA0CBF000BAFA36 /* TimeLineChartRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909437491CA0CBF000BAFA36 /* TimeLineChartRenderer.swift */; };
A52C5C3F1BAC5D1100594CDD /* ChartAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6A546D1AA5D2DC000F57C2 /* ChartAnimator.swift */; };
A52C5C401BAC5D1100594CDD /* ChartAnimationEasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B378F161AD500A4009414A4 /* ChartAnimationEasing.swift */; };
A52C5C411BAC5D1100594CDD /* BarChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6A54981AA66B14000F57C2 /* BarChartView.swift */; };
Expand Down Expand Up @@ -506,6 +508,8 @@
65F06FA91BE818AA0074498D /* IBarChartDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IBarChartDataSet.swift; sourceTree = "<group>"; };
65F06FAC1BE826010074498D /* IPieChartDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IPieChartDataSet.swift; sourceTree = "<group>"; };
65F06FAF1BE826090074498D /* IRadarChartDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IRadarChartDataSet.swift; sourceTree = "<group>"; };
909437461CA0CBC000BAFA36 /* TimeLineChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeLineChartView.swift; sourceTree = "<group>"; };
909437491CA0CBF000BAFA36 /* TimeLineChartRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimeLineChartRenderer.swift; sourceTree = "<group>"; };
A52C5C371BAC5CA400594CDD /* Charts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Charts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarChartTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -603,6 +607,7 @@
5B759ED41A9F98A90039D97F /* Renderers */ = {
isa = PBXGroup;
children = (
909437491CA0CBF000BAFA36 /* TimeLineChartRenderer.swift */,
5B6A54961AA66AD2000F57C2 /* BarChartRenderer.swift */,
55E3565A1ADC63EB00A57971 /* BubbleChartRenderer.swift */,
5B6A54941AA66AC0000F57C2 /* CandleStickChartRenderer.swift */,
Expand Down Expand Up @@ -681,6 +686,7 @@
5BA8EC661A9D151C00CE82E1 /* Charts */ = {
isa = PBXGroup;
children = (
909437461CA0CBC000BAFA36 /* TimeLineChartView.swift */,
5B6A54981AA66B14000F57C2 /* BarChartView.swift */,
5B6A549A1AA66B2C000F57C2 /* BarLineChartViewBase.swift */,
55E356521ADC63BF00A57971 /* BubbleChartView.swift */,
Expand Down Expand Up @@ -1047,6 +1053,7 @@
659400D01BF463C2004F9C27 /* ScatterChartDataSet.swift in Sources */,
659400B21BF463C1004F9C27 /* CandleChartDataEntry.swift in Sources */,
659400B61BF463C1004F9C27 /* ChartData.swift in Sources */,
909437471CA0CBC000BAFA36 /* TimeLineChartView.swift in Sources */,
5B680D221A9D17C30026A057 /* ChartXAxis.swift in Sources */,
5BA8EC891A9D151C00CE82E1 /* ChartDataBaseFilter.swift in Sources */,
659400A21BF463C1004F9C27 /* BarChartDataEntry.swift in Sources */,
Expand All @@ -1072,6 +1079,7 @@
5B00324D1B65351C00B6A2FE /* HorizontalBarChartHighlighter.swift in Sources */,
65F06FB01BE826090074498D /* IRadarChartDataSet.swift in Sources */,
659400C61BF463C1004F9C27 /* PieChartData.swift in Sources */,
9094374B1CA0CBF000BAFA36 /* TimeLineChartRenderer.swift in Sources */,
5B6A54871AA669F4000F57C2 /* RadarChartRenderer.swift in Sources */,
5B6A548D1AA66A60000F57C2 /* ChartLegendRenderer.swift in Sources */,
65F06F941BE812210074498D /* IBarLineScatterCandleBubbleChartDataSet.swift in Sources */,
Expand Down
37 changes: 37 additions & 0 deletions Charts/Classes/Charts/TimeLineChartView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// TimeLineChartView.swift
// Charts
//
// Created by Daniel Cohen Gindi on 4/3/15.
//
// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
// A port of MPAndroidChart for iOS
// Licensed under Apache License 2.0
//
// https://github.com/danielgindi/ios-charts
//

import Foundation
import CoreGraphics

/// Chart that do all that line charts do and also support using the x axis to represent time
public class TimeLineChartView: LineChartView
{
internal override func initialize()
{
super.initialize()

renderer = TimeLineChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler)
}

internal override func calcMinMax()
{
super.calcMinMax()
guard let data = _data else { return }

if (_deltaX == 0.0 && data.yValCount > 0)
{
_deltaX = 1.0
}
}
}
18 changes: 18 additions & 0 deletions Charts/Classes/Data/Implementations/ChartBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ public class ChartBaseDataSet: NSObject, IChartDataSet
fatalError("yMax is not implemented in ChartBaseDataSet")
}

/// Note: xNumericVal is not supported by all chart types
public var xNumericValMin: Double
{
fatalError("xNumericValMin is not implemented in ChartBaseDataSet")
}

/// Note: xNumericVal is not supported by all chart types
public var xNumericValMax: Double
{
fatalError("xNumericValMax is not implemented in ChartBaseDataSet")
}

public var entryCount: Int
{
fatalError("entryCount is not implemented in ChartBaseDataSet")
Expand All @@ -71,6 +83,12 @@ public class ChartBaseDataSet: NSObject, IChartDataSet
fatalError("yValForXIndex is not implemented in ChartBaseDataSet")
}

/// Note: not all chart types support xNumericVal
public func xNumericValForXIndex(x: Int) -> Double
{
fatalError("xNumericValForXIndex is not implemented in ChartBaseDataSet")
}

public func entryForIndex(i: Int) -> ChartDataEntry?
{
fatalError("entryForIndex is not implemented in ChartBaseDataSet")
Expand Down
65 changes: 65 additions & 0 deletions Charts/Classes/Data/Implementations/Standard/ChartData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class ChartData: NSObject
internal var _rightAxisMin = Double(0.0)
private var _yValCount = Int(0)

/// Note: xNumericVal is not supported by all chart types
internal var _xNumericValMax = Double(0.0)
internal var _xNumericValMin = Double(0.0)

/// the last start value used for calcMinMax
internal var _lastStart: Int = 0

Expand Down Expand Up @@ -153,6 +157,8 @@ public class ChartData: NSObject
{
_yMax = 0.0
_yMin = 0.0
_xNumericValMax = 0.0
_xNumericValMin = 0.0
}
else
{
Expand All @@ -161,6 +167,8 @@ public class ChartData: NSObject

_yMin = DBL_MAX
_yMax = -DBL_MAX
_xNumericValMin = DBL_MAX
_xNumericValMax = -DBL_MAX

for (var i = 0; i < _dataSets.count; i++)
{
Expand All @@ -175,12 +183,24 @@ public class ChartData: NSObject
{
_yMax = _dataSets[i].yMax
}

if (_dataSets[i].xNumericValMin < _xNumericValMin)
{
_xNumericValMin = _dataSets[i].xNumericValMin
}

if (_dataSets[i].xNumericValMax > _xNumericValMax)
{
_xNumericValMax = _dataSets[i].xNumericValMax
}
}

if (_yMin == DBL_MAX)
{
_yMin = 0.0
_yMax = 0.0
_xNumericValMin = 0.0
_xNumericValMax = 0.0
}

// left axis
Expand Down Expand Up @@ -314,6 +334,30 @@ public class ChartData: NSObject
}
}

/// - returns: the smallest xNumericVal the data object contains.
/// Note: xNumericVal is not supported by all chart types
public var xNumericValMin: Double
{
return _xNumericValMin
}

public func getXNumericValMin() -> Double
{
return _xNumericValMin
}

/// - returns: the greatest xNumericVal the data object contains.
/// Note: xNumericVal is not supported by all chart types
public var xNumericValMax: Double
{
return _xNumericValMax
}

public func getXNumericValMax() -> Double
{
return _xNumericValMax
}

/// - returns: the average length (in characters) across all values in the x-vals array
public var xValAverageLength: Double
{
Expand Down Expand Up @@ -478,6 +522,8 @@ public class ChartData: NSObject
{
_yMax = d.yMax
_yMin = d.yMin
_xNumericValMax = d.xNumericValMax
_xNumericValMin = d.xNumericValMin

if (d.axisDependency == .Left)
{
Expand All @@ -500,6 +546,14 @@ public class ChartData: NSObject
{
_yMin = d.yMin
}
if (_xNumericValMax < d.xNumericValMax)
{
_xNumericValMax = d.xNumericValMax
}
if (_xNumericValMin > d.xNumericValMin)
{
_xNumericValMin = d.xNumericValMin
}

if (d.axisDependency == .Left)
{
Expand Down Expand Up @@ -592,6 +646,7 @@ public class ChartData: NSObject
if _dataSets != nil && _dataSets.count > dataSetIndex && dataSetIndex >= 0
{
let val = e.value
let xNumericVal = e.xNumericVal
let set = _dataSets[dataSetIndex]

if !set.addEntry(e) { return }
Expand All @@ -600,6 +655,8 @@ public class ChartData: NSObject
{
_yMin = val
_yMax = val
_xNumericValMin = xNumericVal
_xNumericValMax = xNumericVal

if (set.axisDependency == .Left)
{
Expand All @@ -622,6 +679,14 @@ public class ChartData: NSObject
{
_yMin = val
}
if (_xNumericValMax < xNumericVal)
{
_xNumericValMax = xNumericVal
}
if (_xNumericValMin > xNumericVal)
{
_xNumericValMin = xNumericVal
}

if (set.axisDependency == .Left)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class ChartDataEntry: NSObject
/// optional spot for additional data this Entry represents
public var data: AnyObject?

/// optional value to represent a more precise location on the x-axis than the standard xIndex
/// Not supported by all chart types
public var xNumericVal = Double(0.0)

public override required init()
{
super.init()
Expand All @@ -38,6 +42,15 @@ public class ChartDataEntry: NSObject
self.xIndex = xIndex
}

public init(value: Double, xIndex: Int, xNumericVal: Double)
{
super.init()

self.value = value
self.xIndex = xIndex
self.xNumericVal = xNumericVal
}

public init(value: Double, xIndex: Int, data: AnyObject?)
{
super.init()
Expand Down Expand Up @@ -70,8 +83,13 @@ public class ChartDataEntry: NSObject
{
return false
}

if (!ChartUtils.Math.equalDoubles(object!.xNumericVal, doubleB: xNumericVal))
{
return false
}

if (fabs(object!.value - value) > 0.00001)
if (!ChartUtils.Math.equalDoubles(object!.value, doubleB: value))
{
return false
}
Expand All @@ -95,6 +113,7 @@ public class ChartDataEntry: NSObject
copy.value = value
copy.xIndex = xIndex
copy.data = data
copy.xNumericVal = xNumericVal

return copy
}
Expand Down Expand Up @@ -122,6 +141,11 @@ public func ==(lhs: ChartDataEntry, rhs: ChartDataEntry) -> Bool
return false
}

if (fabs(lhs.xNumericVal - rhs.xNumericVal) > 0.00001)
{
return false
}

if (fabs(lhs.value - rhs.value) > 0.00001)
{
return false
Expand Down
Loading