-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Dataset logic cleanup #3001
Changes from 60 commits
5fbf9b4
1feda88
6e80eb0
d36d11b
36ca566
cb32b08
ad0d148
fcd9fa2
5d7a1a1
01d0753
ea240a1
1d819d7
716f182
ca5afad
0d41175
fdae403
8976b95
f28d3d5
793e437
583dab6
0cce64d
47b6a1c
c0b7d65
1d1e380
79cae83
c76ed46
09d27a7
a71f87c
efc5a72
bfb750b
6adde98
023ff19
e6eb970
29d3e91
a388f8a
ae8279a
6de1114
37b29ad
329e00c
2572f04
31a76eb
5cbafb4
b7e6f93
5f3b528
5816632
9f5a7f9
b73ac7e
33ed6b5
8bcccd3
585e605
b1ca0c5
08a8ac0
5faad7b
a049cd3
251f501
8031da7
d371fa8
728fa0e
7d64273
bf7c325
0d4ab69
8f74fe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, BarChartData | |
initialize() | ||
} | ||
|
||
public override init(values: [ChartDataEntry]?, label: String?) | ||
public override init(values: [ChartDataEntry], label: String) | ||
{ | ||
super.init(values: values, label: label) | ||
initialize() | ||
|
@@ -50,68 +50,39 @@ 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 | ||
{ | ||
if let vals = entries[i].yValues | ||
{ | ||
if vals.count > _stackSize | ||
{ | ||
_stackSize = vals.count | ||
} | ||
guard let vals = e.yValues, vals.count > _stackSize else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure the code style here. put all guard sentence one line or use another line for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh, yea I'll fix it. Still find this to be an incredibly weird style for Swift. It's clear even the library was written without any consideration for Swift, and instead other language(s). I think now that there are common accepted practices, we should revisit some of ours. |
||
continue | ||
} | ||
_stackSize = vals.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. | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.