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

Dataset logic cleanup #3001

Merged
merged 62 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5fbf9b4
Cleaned up `ChartDataSet` logic
jjatie Nov 14, 2017
1feda88
Tidied up logic for `ChartDataSet` subclasses
jjatie Nov 14, 2017
6e80eb0
Added Collection conformances
jjatie Nov 18, 2017
d36d11b
[#3018]
jjatie Nov 19, 2017
36ca566
Fixed required initializers
jjatie Nov 20, 2017
cb32b08
ChartData adopts ExressibleByArrayLiteral
jjatie Dec 1, 2017
ad0d148
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Dec 1, 2017
fcd9fa2
Modified demos
jjatie Dec 1, 2017
5d7a1a1
Merge remote-tracking branch 'upstream/master' into dataset-logic-cle…
jjatie Dec 11, 2017
01d0753
Pulled latest master
jjatie Dec 11, 2017
ea240a1
Merge remote-tracking branch 'upstream/master' into dataset-logic-cle…
jjatie Dec 14, 2017
1d819d7
Pulled latest master
jjatie Dec 14, 2017
716f182
Pulled latest 4.0.0 and code style fixes
jjatie Jan 6, 2018
ca5afad
Updates for PR
jjatie Jan 11, 2018
0d41175
Pulled latest base
jjatie Jan 11, 2018
fdae403
Refactored ChartData
jjatie Jan 11, 2018
8976b95
PR review fixes
jjatie Jan 12, 2018
f28d3d5
Removed unnecessary `get` from subscripts.
jjatie Jan 12, 2018
793e437
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
583dab6
Disabled `remove(at:)` for CombinedChartView
jjatie Jan 15, 2018
0cce64d
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
47b6a1c
Removed redundant methods
jjatie Jan 15, 2018
c0b7d65
Relocated `appendEntry(_:todataSet:)`
jjatie Jan 15, 2018
1d1e380
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
79cae83
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 15, 2018
c76ed46
pulled latest 4.0.0
jjatie Jan 15, 2018
09d27a7
Disabled Collection support for CombinedChartData
jjatie Jan 15, 2018
a71f87c
Removed methods from CombinedChartData
jjatie Jan 15, 2018
efc5a72
Merge remote-tracking branch 'origin/chartdata-collection-conformance…
jjatie Jan 15, 2018
bfb750b
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 15, 2018
6adde98
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 15, 2018
023ff19
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 16, 2018
e6eb970
Pulled latest 4.0
jjatie Jan 16, 2018
29d3e91
Fixes after merge
jjatie Jan 16, 2018
a388f8a
Removed used of dataSet(forIndex:)
jjatie Jan 16, 2018
ae8279a
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 16, 2018
6de1114
Merge branch '4.0.0' into chartdata-collection-refactor
jjatie Jan 16, 2018
37b29ad
Merge branch '4.0.0' of https://github.com/danielgindi/Charts into ch…
jjatie Jan 21, 2018
329e00c
Fixed merge conflicts
jjatie Jan 21, 2018
2572f04
Merge remote-tracking branch 'upstream/4.0.0' into chartdata-collecti…
jjatie Jan 23, 2018
31a76eb
Fixed merge conflicts
jjatie Jan 23, 2018
5cbafb4
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 23, 2018
b7e6f93
updated demos
jjatie Jan 26, 2018
5f3b528
Merge remote-tracking branch 'origin/chartdata-collection-refactor' i…
jjatie Jan 26, 2018
5816632
Merge remote-tracking branch 'upstream/4.0.0' into chartdata-cleanup
jjatie Jan 26, 2018
9f5a7f9
Pulled latest 4.0.0
jjatie Jan 26, 2018
b73ac7e
Fixed demos
jjatie Jan 26, 2018
33ed6b5
Fixed objective c demos
jjatie Jan 26, 2018
8bcccd3
Merged latest 4.0.0
jjatie Jan 26, 2018
585e605
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 13, 2018
b1ca0c5
Moved travis to Xcode 9.3 beta temporarily
jjatie Mar 13, 2018
08a8ac0
Pulled latest 4.0.0
jjatie Mar 14, 2018
5faad7b
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 14, 2018
a049cd3
Merge remote-tracking branch 'origin/4.0.0' into chartdata-cleanup
jjatie Mar 14, 2018
251f501
Fixed macOS demo info.plist and tv demo device name
jjatie Mar 14, 2018
8031da7
PR Fixes
jjatie Mar 27, 2018
d371fa8
Fixed objective-c naming
jjatie Mar 27, 2018
728fa0e
Merge branch 'chartdata-cleanup' of https://github.com/jjatie/Charts …
jjatie Mar 27, 2018
7d64273
PR Fixes
jjatie Mar 29, 2018
bf7c325
Pulled latest 4.0.0
jjatie Apr 15, 2018
0d4ab69
Merge remote-tracking branch 'origin/4.0.0' into dataset-logic-cleanup
jjatie Apr 30, 2018
8f74fe0
PR Fixes
jjatie Apr 30, 2018
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
2 changes: 1 addition & 1 deletion Source/Charts/Data/Implementations/ChartBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class ChartBaseDataSet: NSObject, ChartDataSetProtocol
valueColors.append(NSUIColor.black)
}

@objc public init(label: String?)
@objc public init(label: String)
{
super.init()

Expand Down
64 changes: 16 additions & 48 deletions Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, BarChartData
initialize()
}

public override init(values: [ChartDataEntry]?, label: String?)
public override init(values: [ChartDataEntry], label: String)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok to remove, but what's the reason removing all values and labels optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would they be optional? We already have an initializer that doesn't take a label, and backing stores shouldn't be optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

{
super.init(values: values, label: label)
initialize()
Expand All @@ -50,68 +50,36 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, BarChartData
{
_entryCountStacks = 0

for i in 0 ..< entries.count
{
if let vals = entries[i].yValues
{
_entryCountStacks += vals.count
}
else
{
_entryCountStacks += 1
}
}
entries.forEach { _entryCountStacks += $0.yValues?.count ?? 1 }
}

/// calculates the maximum stacksize that occurs in the Entries array of this DataSet
private func calcStackSize(entries: [BarChartDataEntry])
{
for i in 0 ..< entries.count
for e in entries where (e.yValues?.count ?? 0) > _stackSize
{
if let vals = entries[i].yValues
{
if vals.count > _stackSize
{
_stackSize = vals.count
}
}
_stackSize = e.yValues!.count
}
}

open override func calcMinMax(entry e: ChartDataEntry)
{
guard let e = e as? BarChartDataEntry
guard let e = e as? BarChartDataEntry,
!e.y.isNaN
else { return }

if !e.y.isNaN
if e.yValues == nil
{
if e.yValues == nil
{
if e.y < _yMin
{
_yMin = e.y
}

if e.y > _yMax
{
_yMax = e.y
}
}
else
{
if -e.negativeSum < _yMin
{
_yMin = -e.negativeSum
}

if e.positiveSum > _yMax
{
_yMax = e.positiveSum
}
}

calcMinMaxX(entry: e)
_yMin = min(e.y, _yMin)
_yMax = max(e.y, _yMax)
}
else
{
_yMin = min(-e.negativeSum, _yMin)
_yMax = max(e.positiveSum, _yMax)
}

calcMinMaxX(entry: e)
}

/// - returns: The maximum number of bars that can be stacked upon another in this DataSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ open class BubbleChartDataSet: BarLineScatterCandleBubbleChartDataSet, BubbleCha

super.calcMinMax(entry: e)

let size = e.size

if size > _maxSize
{
_maxSize = size
}
_maxSize = max(e.size, maxSize)
}

// MARK: - Styling functions and accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class CandleChartDataSet: LineScatterCandleRadarChartDataSet, CandleChartDa
super.init()
}

public override init(values: [ChartDataEntry]?, label: String?)
public override init(values: [ChartDataEntry], label: String)
{
super.init(values: values, label: label)
}
Expand All @@ -32,68 +32,42 @@ open class CandleChartDataSet: LineScatterCandleRadarChartDataSet, CandleChartDa
{
guard let e = e as? CandleChartDataEntry
else { return }

if e.low < _yMin
{
_yMin = e.low
}

if e.high > _yMax
{
_yMax = e.high
}


_yMin = min(e.low, _yMin)
_yMax = max(e.high, _yMax)

calcMinMaxX(entry: e)
}

open override func calcMinMaxY(entry e: ChartDataEntry)
{
guard let e = e as? CandleChartDataEntry
else { return }

if e.high < _yMin
{
_yMin = e.high
}
if e.high > _yMax
{
_yMax = e.high
}

if e.low < _yMin
{
_yMin = e.low
}
if e.low > _yMax
{
_yMax = e.low
}

_yMin = min(e.low, _yMin)
_yMax = max(e.high, _yMin)

_yMin = min(e.low, _yMax)
_yMax = max(e.high, _yMax)
}

// MARK: - Styling functions and accessors

/// the space between the candle entries
///
/// **default**: 0.1 (10%)
private var _barSpace = CGFloat(0.1)
private var _barSpace: CGFloat = 0.1

/// the space that is left out on the left and right side of each candle,
/// **default**: 0.1 (10%), max 0.45, min 0.0
open var barSpace: CGFloat
{
set
{
if newValue < 0.0
{
_barSpace = 0.0
}
else if newValue > 0.45
{
_barSpace = 0.45
}
else
{
_barSpace = newValue
switch newValue {
case ..<0: _barSpace = 0.0
case 0.45...: _barSpace = 0.45
default: _barSpace = newValue
}
}
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ open class ChartData: NSObject, ExpressibleByArrayLiteral
}

/// - returns: All colors used across all DataSet objects this object represents.
@objc open func getColors() -> [NSUIColor]
@objc open var colors: [NSUIColor]
{
return reduce(into: []) { $0 += $1.colors }
}
Expand Down
Loading