diff --git a/Charts.xcodeproj/project.pbxproj b/Charts.xcodeproj/project.pbxproj index ac86e71d95..693ff6767b 100644 --- a/Charts.xcodeproj/project.pbxproj +++ b/Charts.xcodeproj/project.pbxproj @@ -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 = ""; @@ -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 = ""; diff --git a/ChartsDemo-iOS/Objective-C/Components/BalloonMarker.swift b/ChartsDemo-iOS/Objective-C/Components/BalloonMarker.swift index 51b5f351a7..b4710575ca 100644 --- a/ChartsDemo-iOS/Objective-C/Components/BalloonMarker.swift +++ b/ChartsDemo-iOS/Objective-C/Components/BalloonMarker.swift @@ -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) { diff --git a/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift b/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift index 4e9826bf55..a304c0c808 100644 --- a/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift +++ b/ChartsDemo-iOS/Swift/Components/BalloonMarker.swift @@ -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) { diff --git a/ChartsDemo-macOS/ChartsDemo-macOS/Demos/PieDemoViewController.swift b/ChartsDemo-macOS/ChartsDemo-macOS/Demos/PieDemoViewController.swift index fd2df98598..14c7c7c262 100644 --- a/ChartsDemo-macOS/ChartsDemo-macOS/Demos/PieDemoViewController.swift +++ b/ChartsDemo-macOS/ChartsDemo-macOS/Demos/PieDemoViewController.swift @@ -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 diff --git a/Source/Charts/Animation/Animator.swift b/Source/Charts/Animation/Animator.swift index 042012b1ba..0b4d725ccf 100644 --- a/Source/Charts/Animation/Animator.swift +++ b/Source/Charts/Animation/Animator.swift @@ -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 @@ -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) } } @@ -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) } } @@ -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) } } diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index b64baba3bf..052affae2c 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -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 @@ -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 } } diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 7528e0c75b..29ab832760 100644 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -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, diff --git a/Source/Charts/Charts/PieChartView.swift b/Source/Charts/Charts/PieChartView.swift index 2c4ea8b5d5..71769346b9 100644 --- a/Source/Charts/Charts/PieChartView.swift +++ b/Source/Charts/Charts/PieChartView.swift @@ -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 diff --git a/Source/Charts/Charts/PieRadarChartViewBase.swift b/Source/Charts/Charts/PieRadarChartViewBase.swift index a073d47f33..c6de8ce7c7 100755 --- a/Source/Charts/Charts/PieRadarChartViewBase.swift +++ b/Source/Charts/Charts/PieRadarChartViewBase.swift @@ -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) } } } @@ -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 } } @@ -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) } } } diff --git a/Source/Charts/Components/Legend.swift b/Source/Charts/Components/Legend.swift index 53177d04f5..68e9e9e283 100644 --- a/Source/Charts/Components/Legend.swift +++ b/Source/Charts/Components/Legend.swift @@ -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 diff --git a/Source/Charts/Components/YAxis.swift b/Source/Charts/Components/YAxis.swift index efc48a30e4..4729c1843d 100644 --- a/Source/Charts/Components/YAxis.swift +++ b/Source/Charts/Components/YAxis.swift @@ -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)) diff --git a/Source/Charts/Jobs/AnimatedViewPortJob.swift b/Source/Charts/Jobs/AnimatedViewPortJob.swift index 985358e4b6..eaa9fec170 100644 --- a/Source/Charts/Jobs/AnimatedViewPortJob.swift +++ b/Source/Charts/Jobs/AnimatedViewPortJob.swift @@ -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 diff --git a/Source/Charts/Renderers/BarChartRenderer.swift b/Source/Charts/Renderers/BarChartRenderer.swift index 301fa8f30d..4b97863aad 100644 --- a/Source/Charts/Renderers/BarChartRenderer.swift +++ b/Source/Charts/Renderers/BarChartRenderer.swift @@ -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) diff --git a/Source/Charts/Renderers/BubbleChartRenderer.swift b/Source/Charts/Renderers/BubbleChartRenderer.swift index e182a4be9c..5309092cad 100644 --- a/Source/Charts/Renderers/BubbleChartRenderer.swift +++ b/Source/Charts/Renderers/BubbleChartRenderer.swift @@ -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 diff --git a/Source/Charts/Renderers/CandleStickChartRenderer.swift b/Source/Charts/Renderers/CandleStickChartRenderer.swift index 7324e83a8a..55d5231f11 100644 --- a/Source/Charts/Renderers/CandleStickChartRenderer.swift +++ b/Source/Charts/Renderers/CandleStickChartRenderer.swift @@ -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 diff --git a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift index 0307cd5f9a..4f493bdeea 100644 --- a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift +++ b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift @@ -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) @@ -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) @@ -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) diff --git a/Source/Charts/Renderers/LegendRenderer.swift b/Source/Charts/Renderers/LegendRenderer.swift index 08100e32f7..9c378c3d9b 100755 --- a/Source/Charts/Renderers/LegendRenderer.swift +++ b/Source/Charts/Renderers/LegendRenderer.swift @@ -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]) } } diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index 176a18c022..2d8ae7b02c 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -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 diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index aab8bfe1ec..c1ceb7c1fe 100644 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -457,7 +457,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: labelPoint, align: align, - attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] + attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: valueTextColor] ) if j < data.entryCount && pe?.label != nil @@ -468,8 +468,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight), align: align, attributes: [ - NSAttributedStringKey.font: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] + NSAttributedString.Key.font: entryLabelFont ?? valueFont, + NSAttributedString.Key.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -483,8 +483,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight / 2.0), align: align, attributes: [ - NSAttributedStringKey.font: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] + NSAttributedString.Key.font: entryLabelFont ?? valueFont, + NSAttributedString.Key.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -495,7 +495,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight / 2.0), align: align, - attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] + attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: valueTextColor] ) } } @@ -513,7 +513,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: x, y: y), align: .center, - attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] + attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: valueTextColor] ) if j < data.entryCount && pe?.label != nil @@ -524,8 +524,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: x, y: y + lineHeight), align: .center, attributes: [ - NSAttributedStringKey.font: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] + NSAttributedString.Key.font: entryLabelFont ?? valueFont, + NSAttributedString.Key.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -539,8 +539,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: x, y: y + lineHeight / 2.0), align: .center, attributes: [ - NSAttributedStringKey.font: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] + NSAttributedString.Key.font: entryLabelFont ?? valueFont, + NSAttributedString.Key.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -551,7 +551,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: x, y: y + lineHeight / 2.0), align: .center, - attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] + attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: valueTextColor] ) } } diff --git a/Source/Charts/Renderers/RadarChartRenderer.swift b/Source/Charts/Renderers/RadarChartRenderer.swift index a295fad6ee..a535cfd5d1 100644 --- a/Source/Charts/Renderers/RadarChartRenderer.swift +++ b/Source/Charts/Renderers/RadarChartRenderer.swift @@ -258,8 +258,8 @@ open class RadarChartRenderer: LineRadarRenderer viewPortHandler: viewPortHandler), point: CGPoint(x: p.x, y: p.y - yoffset - valueFont.lineHeight), align: .center, - attributes: [NSAttributedStringKey.font: valueFont, - NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)] + attributes: [NSAttributedString.Key.font: valueFont, + NSAttributedString.Key.foregroundColor: dataSet.valueTextColorAt(j)] ) } diff --git a/Source/Charts/Renderers/ScatterChartRenderer.swift b/Source/Charts/Renderers/ScatterChartRenderer.swift index acff926e0f..f0669cf553 100644 --- a/Source/Charts/Renderers/ScatterChartRenderer.swift +++ b/Source/Charts/Renderers/ScatterChartRenderer.swift @@ -186,7 +186,7 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer x: pt.x, y: pt.y - shapeSize - lineHeight), align: .center, - attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)] + attributes: [NSAttributedString.Key.font: valueFont, NSAttributedString.Key.foregroundColor: dataSet.valueTextColorAt(j)] ) } diff --git a/Source/Charts/Renderers/XAxisRenderer.swift b/Source/Charts/Renderers/XAxisRenderer.swift index 534e606dcf..0cca5116b2 100644 --- a/Source/Charts/Renderers/XAxisRenderer.swift +++ b/Source/Charts/Renderers/XAxisRenderer.swift @@ -68,7 +68,7 @@ open class XAxisRenderer: AxisRendererBase let longest = xAxis.getLongestLabel() - let labelSize = longest.size(withAttributes: [NSAttributedStringKey.font: xAxis.labelFont]) + let labelSize = longest.size(withAttributes: [NSAttributedString.Key.font: xAxis.labelFont]) let labelWidth = labelSize.width let labelHeight = labelSize.height @@ -179,9 +179,9 @@ open class XAxisRenderer: AxisRendererBase #endif paraStyle.alignment = .center - let labelAttrs: [NSAttributedStringKey : Any] = [NSAttributedStringKey.font: xAxis.labelFont, - NSAttributedStringKey.foregroundColor: xAxis.labelTextColor, - NSAttributedStringKey.paragraphStyle: paraStyle] + let labelAttrs: [NSAttributedString.Key : Any] = [NSAttributedString.Key.font: xAxis.labelFont, + NSAttributedString.Key.foregroundColor: xAxis.labelTextColor, + NSAttributedString.Key.paragraphStyle: paraStyle] let labelRotationAngleRadians = xAxis.labelRotationAngle.DEG2RAD let centeringEnabled = xAxis.isCenterAxisLabelsEnabled @@ -256,7 +256,7 @@ open class XAxisRenderer: AxisRendererBase formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [NSAttributedStringKey : Any], + attributes: [NSAttributedString.Key : Any], constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) @@ -423,7 +423,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x + xOffset, y: viewPortHandler.contentTop + yOffset), align: .left, - attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) + attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) } else if limitLine.labelPosition == .rightBottom { @@ -433,7 +433,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x + xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .left, - attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) + attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) } else if limitLine.labelPosition == .leftTop { @@ -443,7 +443,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x - xOffset, y: viewPortHandler.contentTop + yOffset), align: .right, - attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) + attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) } else { @@ -453,7 +453,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x - xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .right, - attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) + attributes: [NSAttributedString.Key.font: limitLine.valueFont, NSAttributedString.Key.foregroundColor: limitLine.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift index fef05d7a49..6c3cd98427 100644 --- a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift @@ -64,7 +64,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer let longest = xAxis.getLongestLabel() as NSString - let labelSize = longest.size(withAttributes: [NSAttributedStringKey.font: xAxis.labelFont]) + let labelSize = longest.size(withAttributes: [NSAttributedString.Key.font: xAxis.labelFont]) let labelWidth = floor(labelSize.width + xAxis.xOffset * 3.5) let labelHeight = labelSize.height @@ -155,7 +155,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer formattedLabel: label, x: pos, y: position.y, - attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor], + attributes: [NSAttributedString.Key.font: labelFont, NSAttributedString.Key.foregroundColor: labelTextColor], anchor: anchor, angleRadians: labelRotationAngleRadians) } @@ -168,7 +168,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [NSAttributedStringKey : Any], + attributes: [NSAttributedString.Key : Any], anchor: CGPoint, angleRadians: CGFloat) { @@ -322,7 +322,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentRight - xOffset, y: position.y - yOffset), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -332,7 +332,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentRight - xOffset, y: position.y + yOffset - labelLineHeight), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -342,7 +342,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentLeft + xOffset, y: position.y - yOffset), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else { @@ -352,7 +352,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentLeft + xOffset, y: position.y + yOffset - labelLineHeight), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/XAxisRendererRadarChart.swift b/Source/Charts/Renderers/XAxisRendererRadarChart.swift index 85aeecbf44..0638f3a19c 100644 --- a/Source/Charts/Renderers/XAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/XAxisRendererRadarChart.swift @@ -64,7 +64,7 @@ open class XAxisRendererRadarChart: XAxisRenderer formattedLabel: label, x: p.x, y: p.y - xAxis.labelRotatedHeight / 2.0, - attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor], + attributes: [NSAttributedString.Key.font: labelFont, NSAttributedString.Key.foregroundColor: labelTextColor], anchor: drawLabelAnchor, angleRadians: labelRotationAngleRadians) } @@ -75,7 +75,7 @@ open class XAxisRendererRadarChart: XAxisRenderer formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [NSAttributedStringKey : Any], + attributes: [NSAttributedString.Key : Any], anchor: CGPoint, angleRadians: CGFloat) { diff --git a/Source/Charts/Renderers/YAxisRenderer.swift b/Source/Charts/Renderers/YAxisRenderer.swift index e5b0802575..f369943842 100644 --- a/Source/Charts/Renderers/YAxisRenderer.swift +++ b/Source/Charts/Renderers/YAxisRenderer.swift @@ -147,7 +147,7 @@ open class YAxisRenderer: AxisRendererBase text: text, point: CGPoint(x: fixedPosition, y: positions[i].y + offset), align: textAlign, - attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor]) + attributes: [NSAttributedString.Key.font: labelFont, NSAttributedString.Key.foregroundColor: labelTextColor]) } } @@ -352,7 +352,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentRight - xOffset, y: position.y - yOffset), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -362,7 +362,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentRight - xOffset, y: position.y + yOffset - labelLineHeight), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -372,7 +372,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentLeft + xOffset, y: position.y - yOffset), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else { @@ -382,7 +382,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentLeft + xOffset, y: position.y + yOffset - labelLineHeight), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift index ba7c51f17f..2e7bd4d5c2 100644 --- a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift @@ -168,7 +168,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer text: text, point: CGPoint(x: positions[i].x, y: fixedPosition - offset), align: .center, - attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor]) + attributes: [NSAttributedString.Key.font: labelFont, NSAttributedString.Key.foregroundColor: labelTextColor]) } } @@ -327,7 +327,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x + xOffset, y: viewPortHandler.contentTop + yOffset), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -337,7 +337,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x + xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .left, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -347,7 +347,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x - xOffset, y: viewPortHandler.contentTop + yOffset), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } else { @@ -357,7 +357,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x - xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .right, - attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) + attributes: [NSAttributedString.Key.font: l.valueFont, NSAttributedString.Key.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/YAxisRendererRadarChart.swift b/Source/Charts/Renderers/YAxisRendererRadarChart.swift index b491975e66..bb3e0b5c04 100644 --- a/Source/Charts/Renderers/YAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererRadarChart.swift @@ -199,8 +199,8 @@ open class YAxisRendererRadarChart: YAxisRenderer point: CGPoint(x: p.x + xOffset, y: p.y - labelLineHeight), align: alignment, attributes: [ - NSAttributedStringKey.font: labelFont, - NSAttributedStringKey.foregroundColor: labelTextColor + NSAttributedString.Key.font: labelFont, + NSAttributedString.Key.foregroundColor: labelTextColor ]) } } diff --git a/Source/Charts/Utils/ChartUtils.swift b/Source/Charts/Utils/ChartUtils.swift index 3746866ccf..741b9b3859 100644 --- a/Source/Charts/Utils/ChartUtils.swift +++ b/Source/Charts/Utils/ChartUtils.swift @@ -156,7 +156,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - open class func drawText(context: CGContext, text: String, point: CGPoint, align: NSTextAlignment, attributes: [NSAttributedStringKey : Any]?) + open class func drawText(context: CGContext, text: String, point: CGPoint, align: NSTextAlignment, attributes: [NSAttributedString.Key : Any]?) { var point = point @@ -176,7 +176,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - open class func drawText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedStringKey : Any]?, anchor: CGPoint, angleRadians: CGFloat) + open class func drawText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedString.Key : Any]?, anchor: CGPoint, angleRadians: CGFloat) { var drawOffset = CGPoint() @@ -228,7 +228,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - internal class func drawMultilineText(context: CGContext, text: String, knownTextSize: CGSize, point: CGPoint, attributes: [NSAttributedStringKey : Any]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) + internal class func drawMultilineText(context: CGContext, text: String, knownTextSize: CGSize, point: CGPoint, attributes: [NSAttributedString.Key : Any]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) { var rect = CGRect(origin: CGPoint(), size: knownTextSize) @@ -276,7 +276,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - internal class func drawMultilineText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedStringKey : Any]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) + internal class func drawMultilineText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedString.Key : Any]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) { let rect = text.boundingRect(with: constrainedToSize, options: .usesLineFragmentOrigin, attributes: attributes, context: nil) drawMultilineText(context: context, text: text, knownTextSize: rect.size, point: point, attributes: attributes, constrainedToSize: constrainedToSize, anchor: anchor, angleRadians: angleRadians) diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index eb60c53dbf..ec50bad2bd 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -13,7 +13,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple public typealias NSUIImage = UIImage public typealias NSUIScrollView = UIScrollView public typealias NSUIGestureRecognizer = UIGestureRecognizer - public typealias NSUIGestureRecognizerState = UIGestureRecognizerState +public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State public typealias NSUIGestureRecognizerDelegate = UIGestureRecognizerDelegate public typealias NSUITapGestureRecognizer = UITapGestureRecognizer public typealias NSUIPanGestureRecognizer = UIPanGestureRecognizer @@ -191,12 +191,12 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple func NSUIImagePNGRepresentation(_ image: NSUIImage) -> Data? { - return UIImagePNGRepresentation(image) + return image.pngData() } func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.8) -> Data? { - return UIImageJPEGRepresentation(image, quality) + return image.jpegData(compressionQuality: quality) } func NSUIMainScreen() -> NSUIScreen?