Skip to content

Commit

Permalink
Merge pull request #3522 from jlcanale/Swift-4.2
Browse files Browse the repository at this point in the history
Changes for Swift 4.2, Xcode 10 and iOS 12
  • Loading branch information
pmairoldi authored Sep 17, 2018
2 parents 4fca1f7 + ed67b78 commit c43b6b6
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 86 deletions.
4 changes: 2 additions & 2 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1180,7 +1180,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Objective-C/Components/BalloonMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class BalloonMarker: MarkerImage
fileprivate var label: String?
fileprivate var _labelSize: CGSize = CGSize()
fileprivate var _paragraphStyle: NSMutableParagraphStyle?
fileprivate var _drawAttributes = [NSAttributedStringKey : AnyObject]()
fileprivate var _drawAttributes = [NSAttributedString.Key : AnyObject]()

@objc public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets)
{
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo-iOS/Swift/Components/BalloonMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class BalloonMarker: MarkerImage
fileprivate var label: String?
fileprivate var _labelSize: CGSize = CGSize()
fileprivate var _paragraphStyle: NSMutableParagraphStyle?
fileprivate var _drawAttributes = [NSAttributedStringKey : AnyObject]()
fileprivate var _drawAttributes = [NSAttributedString.Key : AnyObject]()

public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ open class PieDemoViewController: NSViewController
paragraphStyle.lineBreakMode = .byTruncatingTail
paragraphStyle.alignment = .center
let centerText: NSMutableAttributedString = NSMutableAttributedString(string: "Charts\nby Daniel Cohen Gindi")
centerText.setAttributes([NSAttributedStringKey.font: NSFont(name: "HelveticaNeue-Light", size: 15.0)!, NSAttributedStringKey.paragraphStyle: paragraphStyle], range: NSMakeRange(0, centerText.length))
centerText.addAttributes([NSAttributedStringKey.font: NSFont(name: "HelveticaNeue-Light", size: 13.0)!, NSAttributedStringKey.foregroundColor: NSColor.gray], range: NSMakeRange(10, centerText.length - 10))
centerText.addAttributes([NSAttributedStringKey.font: NSFont(name: "HelveticaNeue-LightItalic", size: 13.0)!, NSAttributedStringKey.foregroundColor: NSColor(red: 51 / 255.0, green: 181 / 255.0, blue: 229 / 255.0, alpha: 1.0)], range: NSMakeRange(centerText.length - 19, 19))
centerText.setAttributes([NSAttributedString.Key.font: NSFont(name: "HelveticaNeue-Light", size: 15.0)!, NSAttributedString.Key.paragraphStyle: paragraphStyle], range: NSMakeRange(0, centerText.length))
centerText.addAttributes([NSAttributedString.Key.font: NSFont(name: "HelveticaNeue-Light", size: 13.0)!, NSAttributedString.Key.foregroundColor: NSColor.gray], range: NSMakeRange(10, centerText.length - 10))
centerText.addAttributes([NSAttributedString.Key.font: NSFont(name: "HelveticaNeue-LightItalic", size: 13.0)!, NSAttributedString.Key.foregroundColor: NSColor(red: 51 / 255.0, green: 181 / 255.0, blue: 229 / 255.0, alpha: 1.0)], range: NSMakeRange(centerText.length - 19, 19))

self.pieChartView.centerAttributedText = centerText

Expand Down
8 changes: 4 additions & 4 deletions Source/Charts/Animation/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ open class Animator: NSObject
{
guard _displayLink != nil else { return }

_displayLink?.remove(from: .main, forMode: .commonModes)
_displayLink?.remove(from: .main, forMode: RunLoop.Mode.common)
_displayLink = nil

_enabledX = false
Expand Down Expand Up @@ -163,7 +163,7 @@ open class Animator: NSObject
if _enabledX || _enabledY
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
_displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
}
}

Expand Down Expand Up @@ -219,7 +219,7 @@ open class Animator: NSObject
_displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.add(to: .main, forMode: .commonModes)
_displayLink?.add(to: .main, forMode: RunLoop.Mode.common)
}
}

Expand Down Expand Up @@ -253,7 +253,7 @@ open class Animator: NSObject
_displayLink == nil
{
_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink?.add(to: .main, forMode: .commonModes)
_displayLink?.add(to: .main, forMode: RunLoop.Mode.common)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
_decelerationVelocity = recognizer.velocity(in: self)

_decelerationDisplayLink = NSUIDisplayLink(target: self, selector: #selector(BarLineChartViewBase.decelerationLoop))
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
}

_isDragging = false
Expand Down Expand Up @@ -832,7 +832,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
{
if _decelerationDisplayLink !== nil
{
_decelerationDisplayLink.remove(from: RunLoop.main, forMode: RunLoopMode.commonModes)
_decelerationDisplayLink.remove(from: RunLoop.main, forMode: RunLoop.Mode.common)
_decelerationDisplayLink = nil
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
let position = description.position ?? CGPoint(x: bounds.width - _viewPortHandler.offsetRight - description.xOffset,
y: bounds.height - _viewPortHandler.offsetBottom - description.yOffset - description.font.lineHeight)

var attrs = [NSAttributedStringKey : Any]()
var attrs = [NSAttributedString.Key : Any]()

attrs[NSAttributedStringKey.font] = description.font
attrs[NSAttributedStringKey.foregroundColor] = description.textColor
attrs[NSAttributedString.Key.font] = description.font
attrs[NSAttributedString.Key.foregroundColor] = description.textColor

ChartUtils.drawText(
context: context,
Expand Down
6 changes: 3 additions & 3 deletions Source/Charts/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ open class PieChartView: PieRadarChartViewBase

attrString = NSMutableAttributedString(string: newValue!)
attrString?.setAttributes([
NSAttributedStringKey.foregroundColor: NSUIColor.black,
NSAttributedStringKey.font: NSUIFont.systemFont(ofSize: 12.0),
NSAttributedStringKey.paragraphStyle: paragraphStyle
NSAttributedString.Key.foregroundColor: NSUIColor.black,
NSAttributedString.Key.font: NSUIFont.systemFont(ofSize: 12.0),
NSAttributedString.Key.paragraphStyle: paragraphStyle
], range: NSMakeRange(0, attrString!.length))
}
self.centerAttributedText = attrString
Expand Down
6 changes: 3 additions & 3 deletions Source/Charts/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ open class PieRadarChartViewBase: ChartViewBase
{
_decelerationLastTime = CACurrentMediaTime()
_decelerationDisplayLink = NSUIDisplayLink(target: self, selector: #selector(PieRadarChartViewBase.decelerationLoop))
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
}
}
}
Expand Down Expand Up @@ -768,7 +768,7 @@ open class PieRadarChartViewBase: ChartViewBase
{
if _decelerationDisplayLink !== nil
{
_decelerationDisplayLink.remove(from: RunLoop.main, forMode: RunLoopMode.commonModes)
_decelerationDisplayLink.remove(from: RunLoop.main, forMode: RunLoop.Mode.common)
_decelerationDisplayLink = nil
}
}
Expand Down Expand Up @@ -857,7 +857,7 @@ open class PieRadarChartViewBase: ChartViewBase
{
_decelerationLastTime = CACurrentMediaTime()
_decelerationDisplayLink = NSUIDisplayLink(target: self, selector: #selector(PieRadarChartViewBase.decelerationLoop))
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
_decelerationDisplayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/Legend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ open class Legend: ComponentBase

// Start calculating layout

let labelAttrs = [NSAttributedStringKey.font: labelFont]
let labelAttrs = [NSAttributedString.Key.font: labelFont]
var maxLineWidth: CGFloat = 0.0
var currentLineWidth: CGFloat = 0.0
var requiredWidth: CGFloat = 0.0
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/YAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ open class YAxis: AxisBase
@objc open func requiredSize() -> CGSize
{
let label = getLongestLabel() as NSString
var size = label.size(withAttributes: [NSAttributedStringKey.font: labelFont])
var size = label.size(withAttributes: [NSAttributedString.Key.font: labelFont])
size.width += xOffset * 2.0
size.height += yOffset * 2.0
size.width = max(minWidth, min(size.width, maxWidth > 0.0 ? maxWidth : size.width))
Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Jobs/AnimatedViewPortJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ open class AnimatedViewPortJob: ViewPortJob
updateAnimationPhase(_startTime)

_displayLink = NSUIDisplayLink(target: self, selector: #selector(animationLoop))
_displayLink.add(to: .main, forMode: .commonModes)
_displayLink.add(to: .main, forMode: RunLoop.Mode.common)
}

@objc open func stop(finish: Bool)
{
guard _displayLink != nil else { return }

_displayLink.remove(from: .main, forMode: .commonModes)
_displayLink.remove(from: .main, forMode: RunLoop.Mode.common)
_displayLink = nil

if finish
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
/// Draws a value at the specified x and y position.
@objc open func drawValue(context: CGContext, value: String, xPos: CGFloat, yPos: CGFloat, font: NSUIFont, align: NSTextAlignment, color: NSUIColor)
{
ChartUtils.drawText(context: context, text: value, point: CGPoint(x: xPos, y: yPos), align: align, attributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: color])
ChartUtils.drawText(context: context, text: value, point: CGPoint(x: xPos, y: yPos), align: align, attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: color])
}

open override func drawExtras(context: CGContext)
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/BubbleChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer
x: pt.x,
y: pt.y - (0.5 * lineHeight)),
align: .center,
attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor])
attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: valueTextColor])
}

if let icon = e.icon, dataSet.isDrawIconsEnabled
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/CandleStickChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer
x: pt.x,
y: pt.y - yOffset),
align: .center,
attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)])
attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: dataSet.valueTextColorAt(j)])
}

if let icon = e.icon, dataSet.isDrawIconsEnabled
Expand Down
6 changes: 3 additions & 3 deletions Source/Charts/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer
viewPortHandler: viewPortHandler)

// calculate the correct offset depending on the draw position of the value
let valueTextWidth = valueText.size(withAttributes: [NSAttributedStringKey.font: valueFont]).width
let valueTextWidth = valueText.size(withAttributes: [NSAttributedString.Key.font: valueFont]).width
posOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus))
negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus)

Expand Down Expand Up @@ -472,7 +472,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer
viewPortHandler: viewPortHandler)

// calculate the correct offset depending on the draw position of the value
let valueTextWidth = valueText.size(withAttributes: [NSAttributedStringKey.font: valueFont]).width
let valueTextWidth = valueText.size(withAttributes: [NSAttributedString.Key.font: valueFont]).width
posOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus))
negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus)

Expand Down Expand Up @@ -556,7 +556,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer
viewPortHandler: viewPortHandler)

// calculate the correct offset depending on the draw position of the value
let valueTextWidth = valueText.size(withAttributes: [NSAttributedStringKey.font: valueFont]).width
let valueTextWidth = valueText.size(withAttributes: [NSAttributedString.Key.font: valueFont]).width
posOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus))
negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus)

Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/LegendRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,6 @@ open class LegendRenderer: Renderer
/// Draws the provided label at the given position.
@objc open func drawLabel(context: CGContext, x: CGFloat, y: CGFloat, label: String, font: NSUIFont, textColor: NSUIColor)
{
ChartUtils.drawText(context: context, text: label, point: CGPoint(x: x, y: y), align: .left, attributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: textColor])
ChartUtils.drawText(context: context, text: label, point: CGPoint(x: x, y: y), align: .left, attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor])
}
}
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/LineChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ open class LineChartRenderer: LineRadarRenderer
x: pt.x,
y: pt.y - CGFloat(valOffset) - valueFont.lineHeight),
align: .center,
attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)])
attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: dataSet.valueTextColorAt(j)])
}

if let icon = e.icon, dataSet.isDrawIconsEnabled
Expand Down
Loading

0 comments on commit c43b6b6

Please sign in to comment.