Skip to content

Commit

Permalink
Fix warnings on current code base (#4321)
Browse files Browse the repository at this point in the history
* Fix warnings for vars;
Fix unused instants
Remove a duplicated function NSUIMainScreen()

* use extension to replace NSUIMainScreen()
  • Loading branch information
liuxuan30 committed Apr 16, 2020
1 parent 3544de5 commit 915becb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
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?
{
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

0 comments on commit 915becb

Please sign in to comment.