-
-
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
unwrap optionals #2698
unwrap optionals #2698
Changes from all commits
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 |
---|---|---|
|
@@ -163,11 +163,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
open override func draw(_ rect: CGRect) | ||
{ | ||
super.draw(rect) | ||
|
||
if _data === nil | ||
{ | ||
return | ||
} | ||
|
||
guard data != nil, let renderer = renderer else { return } | ||
|
||
let optionalContext = NSUIGraphicsGetCurrentContext() | ||
guard let context = optionalContext else { return } | ||
|
@@ -223,17 +220,17 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
// make sure the data cannot be drawn outside the content-rect | ||
context.saveGState() | ||
context.clip(to: _viewPortHandler.contentRect) | ||
renderer?.drawData(context: context) | ||
renderer.drawData(context: context) | ||
|
||
// if highlighting is enabled | ||
if (valuesToHighlight()) | ||
{ | ||
renderer?.drawHighlighted(context: context, indices: _indicesToHighlight) | ||
renderer.drawHighlighted(context: context, indices: _indicesToHighlight) | ||
} | ||
|
||
context.restoreGState() | ||
|
||
renderer!.drawExtras(context: context) | ||
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. Why not use Logically, a 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. done |
||
renderer.drawExtras(context: context) | ||
|
||
if _xAxis.isEnabled && !_xAxis.isDrawLimitLinesBehindDataEnabled | ||
{ | ||
|
@@ -259,13 +256,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
context.saveGState() | ||
context.clip(to: _viewPortHandler.contentRect) | ||
|
||
renderer!.drawValues(context: context) | ||
renderer.drawValues(context: context) | ||
|
||
context.restoreGState() | ||
} | ||
else | ||
{ | ||
renderer!.drawValues(context: context) | ||
renderer.drawValues(context: context) | ||
} | ||
|
||
_legendRenderer.renderLegend(context: context) | ||
|
@@ -529,19 +526,19 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
|
||
if recognizer.state == NSUIGestureRecognizerState.ended | ||
{ | ||
if !self.isHighLightPerTapEnabled { return } | ||
if !isHighLightPerTapEnabled { return } | ||
|
||
let h = getHighlightByTouchPoint(recognizer.location(in: self)) | ||
|
||
if h === nil || h!.isEqual(self.lastHighlighted) | ||
if h?.isEqual(lastHighlighted) ?? true | ||
{ | ||
self.highlightValue(nil, callDelegate: true) | ||
self.lastHighlighted = nil | ||
highlightValue(nil, callDelegate: true) | ||
lastHighlighted = nil | ||
} | ||
else | ||
{ | ||
self.highlightValue(h, callDelegate: true) | ||
self.lastHighlighted = h | ||
highlightValue(h, callDelegate: true) | ||
lastHighlighted = h | ||
} | ||
} | ||
} | ||
|
@@ -751,9 +748,9 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
|
||
let lastHighlighted = self.lastHighlighted | ||
|
||
if ((h === nil && lastHighlighted !== nil) || | ||
if (h === nil && lastHighlighted !== nil) || | ||
(h !== nil && lastHighlighted === nil) || | ||
(h !== nil && lastHighlighted !== nil && !h!.isEqual(lastHighlighted))) | ||
(lastHighlighted !== nil && !(h?.isEqual(lastHighlighted) ?? true)) | ||
{ | ||
self.lastHighlighted = h | ||
self.highlightValue(h, callDelegate: true) | ||
|
@@ -931,7 +928,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
)) | ||
{ | ||
var scrollView = self.superview | ||
while (scrollView !== nil && !scrollView!.isKind(of: NSUIScrollView.self)) | ||
while !(scrollView?.isKind(of: NSUIScrollView.self) ?? true) | ||
{ | ||
scrollView = scrollView?.superview | ||
} | ||
|
@@ -946,23 +943,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD | |
|
||
var foundScrollView = scrollView as? NSUIScrollView | ||
|
||
if foundScrollView !== nil && !foundScrollView!.nsuiIsScrollEnabled | ||
if !(foundScrollView?.nsuiIsScrollEnabled ?? true) | ||
{ | ||
foundScrollView = nil | ||
} | ||
|
||
var scrollViewPanGestureRecognizer: NSUIGestureRecognizer! | ||
|
||
if foundScrollView !== nil | ||
{ | ||
for scrollRecognizer in foundScrollView!.nsuiGestureRecognizers! | ||
{ | ||
if scrollRecognizer.isKind(of: NSUIPanGestureRecognizer.self) | ||
{ | ||
scrollViewPanGestureRecognizer = scrollRecognizer as! NSUIPanGestureRecognizer | ||
break | ||
} | ||
} | ||
let scrollViewPanGestureRecognizer = foundScrollView?.nsuiGestureRecognizers?.first { | ||
$0 is NSUIPanGestureRecognizer | ||
} | ||
|
||
if otherGestureRecognizer === scrollViewPanGestureRecognizer | ||
|
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.
This can be one line as well.
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.
done