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

Fix warnings on current code base #4321

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
/// - Returns: The bitmap that represents the chart.
@objc open func getChartImage(transparent: Bool) -> NSUIImage?
{
NSUIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque || !transparent, NSUIMainScreen()?.nsuiScale ?? 1.0)
NSUIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque || !transparent, NSUIScreen.nsuiMain?.nsuiScale ?? 1.0)

guard let context = NSUIGraphicsGetCurrentContext()
else { return nil }
Expand Down
12 changes: 5 additions & 7 deletions Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ open class PieChartRenderer: DataRenderer
// get whole the radius
let radius = chart.radius
let rotationAngle = chart.rotationAngle
var drawAngles = chart.drawAngles
var absoluteAngles = chart.absoluteAngles
let drawAngles = chart.drawAngles
let absoluteAngles = chart.absoluteAngles

let phaseX = animator.phaseX
let phaseY = animator.phaseY
Expand All @@ -321,14 +321,12 @@ open class PieChartRenderer: DataRenderer

let labelRadius = radius - labelRadiusOffset

var dataSets = data.dataSets
let dataSets = data.dataSets

let yValueSum = (data as! PieChartData).yValueSum

let drawEntryLabels = chart.isDrawEntryLabelsEnabled
let usePercentValuesEnabled = chart.usePercentValuesEnabled
let entryLabelColor = chart.entryLabelColor
let entryLabelFont = chart.entryLabelFont

var angle: CGFloat = 0.0
var xIndex = 0
Expand All @@ -353,7 +351,7 @@ open class PieChartRenderer: DataRenderer
let yValuePosition = dataSet.yValuePosition

let valueFont = dataSet.valueFont
let entryLabelFont = dataSet.entryLabelFont
let entryLabelFont = dataSet.entryLabelFont ?? chart.entryLabelFont
let lineHeight = valueFont.lineHeight

guard let formatter = dataSet.valueFormatter else { continue }
Expand Down Expand Up @@ -399,7 +397,7 @@ open class PieChartRenderer: DataRenderer
let drawYInside = drawValues && yValuePosition == .insideSlice

let valueTextColor = dataSet.valueTextColorAt(j)
let entryLabelColor = dataSet.entryLabelColor
let entryLabelColor = dataSet.entryLabelColor ?? chart.entryLabelColor

if drawXOutside || drawYOutside
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer
let transformer = self.transformer
else { return }

var limitLines = xAxis.limitLines
let limitLines = xAxis.limitLines

if limitLines.count == 0
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/YAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ open class YAxisRenderer: AxisRendererBase
let transformer = self.transformer
else { return }

var limitLines = yAxis.limitLines
let limitLines = yAxis.limitLines

if limitLines.count == 0
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer
let transformer = self.transformer
else { return }

var limitLines = yAxis.limitLines
let limitLines = yAxis.limitLines

if limitLines.count <= 0
{
Expand Down
13 changes: 4 additions & 9 deletions Source/Charts/Utils/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ extension UIScreen
}
}

func NSUIMainScreen() -> NSUIScreen?
Copy link
Member Author

@liuxuan30 liuxuan30 Mar 30, 2020

Choose a reason for hiding this comment

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

@jjatie I found this func is duplicated during half pie chart review. They are repeated under two macros iOS & macOS; I manually tested on my iOS simulator and macOS, it seems we only need one outside these macros. We are safe to delete one right? I don't come up a case that we need to put them into two places

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea, we don't need both. Really this should be an extension on NSUIScreen

extension NSUIScreen {
    var nsuiMain: Self? { .main }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@jjatie I have pushed a new commit. but mine is

class var nsuiMain: NSUIScreen? { .main }

is there any reason to use Self? here? Because if I use Self?, Xcode would complain

Type 'Self?' has no member 'main'

and I have to use something like

class var nsuiMain: Self? { NSUIScreen.main as? Self }

(I can't even use { .main as? Self } ) So I think use NSUIScreen explicitly makes it cleaner.

{
return NSUIScreen.main
}

#endif

#if os(OSX)
Expand Down Expand Up @@ -237,9 +232,9 @@ extension NSScrollView
}
}

func NSUIMainScreen() -> NSUIScreen?
#endif

extension NSUIScreen
{
return NSUIScreen.main
class var nsuiMain: NSUIScreen? { .main }
}

#endif