From a9e1e70879dd0bbb6068f9ccc2ca8f23841317e2 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Airoldi Date: Wed, 6 Sep 2017 23:09:31 -0400 Subject: [PATCH] fix build errors after migration --- Source/Charts/Charts/ChartViewBase.swift | 6 ++--- Source/Charts/Charts/PieChartView.swift | 5 ++-- Source/Charts/Components/Description.swift | 2 +- Source/Charts/Components/MarkerView.swift | 4 ++-- .../Charts/Renderers/BarChartRenderer.swift | 2 +- .../Renderers/BubbleChartRenderer.swift | 2 +- .../Renderers/CandleStickChartRenderer.swift | 2 +- Source/Charts/Renderers/LegendRenderer.swift | 2 +- .../Charts/Renderers/LineChartRenderer.swift | 2 +- .../Charts/Renderers/PieChartRenderer.swift | 24 +++++++++---------- .../Charts/Renderers/RadarChartRenderer.swift | 4 ++-- .../Renderers/ScatterChartRenderer.swift | 2 +- Source/Charts/Renderers/XAxisRenderer.swift | 16 ++++++------- .../XAxisRendererHorizontalBarChart.swift | 12 +++++----- .../Renderers/XAxisRendererRadarChart.swift | 4 ++-- Source/Charts/Renderers/YAxisRenderer.swift | 10 ++++---- .../YAxisRendererHorizontalBarChart.swift | 10 ++++---- .../Renderers/YAxisRendererRadarChart.swift | 4 ++-- Source/Charts/Utils/ChartUtils.swift | 8 +++---- Source/Charts/Utils/Platform.swift | 16 ++++++------- 20 files changed, 69 insertions(+), 68 deletions(-) diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 13f2d08273..1b17d817fc 100755 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -367,8 +367,8 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate text: noDataText, point: CGPoint(x: frame.width / 2.0, y: frame.height / 2.0), attributes: - [NSAttributedStringKey.font.rawValue: noDataFont, - NSAttributedStringKey.foregroundColor.rawValue: noDataTextColor], + [NSAttributedStringKey.font: noDataFont, + NSAttributedStringKey.foregroundColor: noDataTextColor], constrainedToSize: self.bounds.size, anchor: CGPoint(x: 0.5, y: 0.5), angleRadians: 0.0) @@ -405,7 +405,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate y: frame.height - _viewPortHandler.offsetBottom - description.yOffset - description.font.lineHeight) } - var attrs = [String : AnyObject]() + var attrs = [NSAttributedStringKey : Any]() attrs[NSAttributedStringKey.font] = description.font attrs[NSAttributedStringKey.foregroundColor] = description.textColor diff --git a/Source/Charts/Charts/PieChartView.swift b/Source/Charts/Charts/PieChartView.swift index 33bda206d9..c6c17aaa93 100755 --- a/Source/Charts/Charts/PieChartView.swift +++ b/Source/Charts/Charts/PieChartView.swift @@ -385,11 +385,12 @@ open class PieChartView: PieRadarChartViewBase else { #if os(OSX) - let paragraphStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle + let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle + paragraphStyle.lineBreakMode = NSParagraphStyle.LineBreakMode.byTruncatingTail #else let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle + paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail #endif - paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail paragraphStyle.alignment = .center attrString = NSMutableAttributedString(string: newValue!) diff --git a/Source/Charts/Components/Description.swift b/Source/Charts/Components/Description.swift index 972d595dac..e6525771e6 100644 --- a/Source/Charts/Components/Description.swift +++ b/Source/Charts/Components/Description.swift @@ -21,7 +21,7 @@ open class Description: ComponentBase // 23 is the smallest recommended font size on the TV font = NSUIFont.systemFont(ofSize: 23) #elseif os(OSX) - font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize()) + font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize) #else font = NSUIFont.systemFont(ofSize: 8.0) #endif diff --git a/Source/Charts/Components/MarkerView.swift b/Source/Charts/Components/MarkerView.swift index 2210df1906..886fd275d7 100644 --- a/Source/Charts/Components/MarkerView.swift +++ b/Source/Charts/Components/MarkerView.swift @@ -82,10 +82,10 @@ open class MarkerView: NSUIView, IMarker #else var loadedObjects = NSArray() - let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer(&loadedObjects) + let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer(&loadedObjects) if Bundle.main.loadNibNamed( - String(describing: self), + NSNib.Name(String(describing: self)), owner: nil, topLevelObjects: loadedObjectsPointer) { diff --git a/Source/Charts/Renderers/BarChartRenderer.swift b/Source/Charts/Renderers/BarChartRenderer.swift index a3538eaa3c..8aa3bc9b0a 100644 --- a/Source/Charts/Renderers/BarChartRenderer.swift +++ b/Source/Charts/Renderers/BarChartRenderer.swift @@ -617,7 +617,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.rawValue: font, NSAttributedStringKey.foregroundColor.rawValue: color]) + ChartUtils.drawText(context: context, text: value, point: CGPoint(x: xPos, y: yPos), align: align, attributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: color]) } open override func drawExtras(context: CGContext) diff --git a/Source/Charts/Renderers/BubbleChartRenderer.swift b/Source/Charts/Renderers/BubbleChartRenderer.swift index ffde81c1ae..4f4265db3b 100644 --- a/Source/Charts/Renderers/BubbleChartRenderer.swift +++ b/Source/Charts/Renderers/BubbleChartRenderer.swift @@ -213,7 +213,7 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer x: pt.x, y: pt.y - (0.5 * lineHeight)), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: valueTextColor]) + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor]) } if let icon = e.icon, dataSet.isDrawIconsEnabled diff --git a/Source/Charts/Renderers/CandleStickChartRenderer.swift b/Source/Charts/Renderers/CandleStickChartRenderer.swift index 44ab0f35d0..2b897aadf9 100644 --- a/Source/Charts/Renderers/CandleStickChartRenderer.swift +++ b/Source/Charts/Renderers/CandleStickChartRenderer.swift @@ -308,7 +308,7 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer x: pt.x, y: pt.y - yOffset), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: dataSet.valueTextColorAt(j)]) + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)]) } if let icon = e.icon, dataSet.isDrawIconsEnabled diff --git a/Source/Charts/Renderers/LegendRenderer.swift b/Source/Charts/Renderers/LegendRenderer.swift index 219ea198a8..aab91b24ad 100755 --- a/Source/Charts/Renderers/LegendRenderer.swift +++ b/Source/Charts/Renderers/LegendRenderer.swift @@ -571,6 +571,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.rawValue: font, NSAttributedStringKey.foregroundColor.rawValue: textColor]) + ChartUtils.drawText(context: context, text: label, point: CGPoint(x: x, y: y), align: .left, attributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: textColor]) } } diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index 107d70b72d..fbb1f7be30 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -580,7 +580,7 @@ open class LineChartRenderer: LineRadarRenderer x: pt.x, y: pt.y - CGFloat(valOffset) - valueFont.lineHeight), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: dataSet.valueTextColorAt(j)]) + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.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 0ffc0bbe8e..2ad91ccddc 100755 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -431,7 +431,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: labelPoint, align: align, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: valueTextColor] + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] ) if j < data.entryCount && pe?.label != nil @@ -442,8 +442,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight), align: align, attributes: [ - NSAttributedStringKey.font.rawValue: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor.rawValue: entryLabelColor ?? valueTextColor] + NSAttributedStringKey.font: entryLabelFont ?? valueFont, + NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -457,8 +457,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight / 2.0), align: align, attributes: [ - NSAttributedStringKey.font.rawValue: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor.rawValue: entryLabelColor ?? valueTextColor] + NSAttributedStringKey.font: entryLabelFont ?? valueFont, + NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -469,7 +469,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: labelPoint.x, y: labelPoint.y + lineHeight / 2.0), align: align, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: valueTextColor] + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] ) } } @@ -487,7 +487,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: x, y: y), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: valueTextColor] + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] ) if j < data.entryCount && pe?.label != nil @@ -498,8 +498,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: x, y: y + lineHeight), align: .center, attributes: [ - NSAttributedStringKey.font.rawValue: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor.rawValue: entryLabelColor ?? valueTextColor] + NSAttributedStringKey.font: entryLabelFont ?? valueFont, + NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -513,8 +513,8 @@ open class PieChartRenderer: DataRenderer point: CGPoint(x: x, y: y + lineHeight / 2.0), align: .center, attributes: [ - NSAttributedStringKey.font.rawValue: entryLabelFont ?? valueFont, - NSAttributedStringKey.foregroundColor.rawValue: entryLabelColor ?? valueTextColor] + NSAttributedStringKey.font: entryLabelFont ?? valueFont, + NSAttributedStringKey.foregroundColor: entryLabelColor ?? valueTextColor] ) } } @@ -525,7 +525,7 @@ open class PieChartRenderer: DataRenderer text: valueText, point: CGPoint(x: x, y: y + lineHeight / 2.0), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: valueTextColor] + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: valueTextColor] ) } } diff --git a/Source/Charts/Renderers/RadarChartRenderer.swift b/Source/Charts/Renderers/RadarChartRenderer.swift index 9000576555..57068555f7 100644 --- a/Source/Charts/Renderers/RadarChartRenderer.swift +++ b/Source/Charts/Renderers/RadarChartRenderer.swift @@ -194,8 +194,8 @@ open class RadarChartRenderer: LineRadarRenderer viewPortHandler: viewPortHandler), point: CGPoint(x: p.x, y: p.y - yoffset - valueFont.lineHeight), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, - NSAttributedStringKey.foregroundColor.rawValue: dataSet.valueTextColorAt(j)] + attributes: [NSAttributedStringKey.font: valueFont, + NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)] ) } diff --git a/Source/Charts/Renderers/ScatterChartRenderer.swift b/Source/Charts/Renderers/ScatterChartRenderer.swift index bc2f5bd088..c9148caa7b 100644 --- a/Source/Charts/Renderers/ScatterChartRenderer.swift +++ b/Source/Charts/Renderers/ScatterChartRenderer.swift @@ -178,7 +178,7 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer x: pt.x, y: pt.y - shapeSize - lineHeight), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: valueFont, NSAttributedStringKey.foregroundColor.rawValue: dataSet.valueTextColorAt(j)] + attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)] ) } diff --git a/Source/Charts/Renderers/XAxisRenderer.swift b/Source/Charts/Renderers/XAxisRenderer.swift index b53072e35c..47a0a806ea 100644 --- a/Source/Charts/Renderers/XAxisRenderer.swift +++ b/Source/Charts/Renderers/XAxisRenderer.swift @@ -184,15 +184,15 @@ open class XAxisRenderer: AxisRendererBase else { return } #if os(OSX) - let paraStyle = NSParagraphStyle.default().mutableCopy() as! NSMutableParagraphStyle + let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle #else let paraStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle #endif paraStyle.alignment = .center - let labelAttrs = [NSAttributedStringKey.font.rawValue: xAxis.labelFont, + let labelAttrs: [NSAttributedStringKey : Any] = [NSAttributedStringKey.font: xAxis.labelFont, NSAttributedStringKey.foregroundColor: xAxis.labelTextColor, - NSAttributedStringKey.paragraphStyle: paraStyle] as! [String : NSObject] + NSAttributedStringKey.paragraphStyle: paraStyle] let labelRotationAngleRadians = xAxis.labelRotationAngle * ChartUtils.Math.FDEG2RAD let centeringEnabled = xAxis.isCenterAxisLabelsEnabled @@ -267,7 +267,7 @@ open class XAxisRenderer: AxisRendererBase formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [String: NSObject], + attributes: [NSAttributedStringKey : Any], constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) @@ -445,7 +445,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x + xOffset, y: viewPortHandler.contentTop + yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: limitLine.valueFont, NSAttributedStringKey.foregroundColor.rawValue: limitLine.valueTextColor]) + attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) } else if limitLine.labelPosition == .rightBottom { @@ -455,7 +455,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x + xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: limitLine.valueFont, NSAttributedStringKey.foregroundColor.rawValue: limitLine.valueTextColor]) + attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) } else if limitLine.labelPosition == .leftTop { @@ -465,7 +465,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x - xOffset, y: viewPortHandler.contentTop + yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: limitLine.valueFont, NSAttributedStringKey.foregroundColor.rawValue: limitLine.valueTextColor]) + attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) } else { @@ -475,7 +475,7 @@ open class XAxisRenderer: AxisRendererBase x: position.x - xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: limitLine.valueFont, NSAttributedStringKey.foregroundColor.rawValue: limitLine.valueTextColor]) + attributes: [NSAttributedStringKey.font: limitLine.valueFont, NSAttributedStringKey.foregroundColor: limitLine.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift index 577ef93a7b..103d5c8ab0 100644 --- a/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift @@ -162,7 +162,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer formattedLabel: label, x: pos, y: position.y, - attributes: [NSAttributedStringKey.font.rawValue: labelFont, NSAttributedStringKey.foregroundColor.rawValue: labelTextColor], + attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor], anchor: anchor, angleRadians: labelRotationAngleRadians) } @@ -175,7 +175,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [String: NSObject], + attributes: [NSAttributedStringKey : Any], anchor: CGPoint, angleRadians: CGFloat) { @@ -337,7 +337,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentRight - xOffset, y: position.y - yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -347,7 +347,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentRight - xOffset, y: position.y + yOffset - labelLineHeight), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -357,7 +357,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentLeft + xOffset, y: position.y - yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else { @@ -367,7 +367,7 @@ open class XAxisRendererHorizontalBarChart: XAxisRenderer x: viewPortHandler.contentLeft + xOffset, y: position.y + yOffset - labelLineHeight), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/XAxisRendererRadarChart.swift b/Source/Charts/Renderers/XAxisRendererRadarChart.swift index c5f920cc10..2f78ce2303 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.rawValue: labelFont, NSAttributedStringKey.foregroundColor.rawValue: labelTextColor], + attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor], anchor: drawLabelAnchor, angleRadians: labelRotationAngleRadians) } @@ -75,7 +75,7 @@ open class XAxisRendererRadarChart: XAxisRenderer formattedLabel: String, x: CGFloat, y: CGFloat, - attributes: [String: NSObject], + attributes: [NSAttributedStringKey : Any], anchor: CGPoint, angleRadians: CGFloat) { diff --git a/Source/Charts/Renderers/YAxisRenderer.swift b/Source/Charts/Renderers/YAxisRenderer.swift index 8cd05d2568..ed429bc87a 100644 --- a/Source/Charts/Renderers/YAxisRenderer.swift +++ b/Source/Charts/Renderers/YAxisRenderer.swift @@ -153,7 +153,7 @@ open class YAxisRenderer: AxisRendererBase text: text, point: CGPoint(x: fixedPosition, y: positions[i].y + offset), align: textAlign, - attributes: [NSAttributedStringKey.font.rawValue: labelFont, NSAttributedStringKey.foregroundColor.rawValue: labelTextColor]) + attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor]) } } @@ -364,7 +364,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentRight - xOffset, y: position.y - yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -374,7 +374,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentRight - xOffset, y: position.y + yOffset - labelLineHeight), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -384,7 +384,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentLeft + xOffset, y: position.y - yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else { @@ -394,7 +394,7 @@ open class YAxisRenderer: AxisRendererBase x: viewPortHandler.contentLeft + xOffset, y: position.y + yOffset - labelLineHeight), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift index 2b0cb07d88..0296fe1f7f 100644 --- a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift @@ -177,7 +177,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer text: text, point: CGPoint(x: positions[i].x, y: fixedPosition - offset), align: .center, - attributes: [NSAttributedStringKey.font.rawValue: labelFont, NSAttributedStringKey.foregroundColor.rawValue: labelTextColor]) + attributes: [NSAttributedStringKey.font: labelFont, NSAttributedStringKey.foregroundColor: labelTextColor]) } } @@ -342,7 +342,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x + xOffset, y: viewPortHandler.contentTop + yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .rightBottom { @@ -352,7 +352,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x + xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .left, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else if l.labelPosition == .leftTop { @@ -362,7 +362,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x - xOffset, y: viewPortHandler.contentTop + yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } else { @@ -372,7 +372,7 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer x: position.x - xOffset, y: viewPortHandler.contentBottom - labelLineHeight - yOffset), align: .right, - attributes: [NSAttributedStringKey.font.rawValue: l.valueFont, NSAttributedStringKey.foregroundColor.rawValue: l.valueTextColor]) + attributes: [NSAttributedStringKey.font: l.valueFont, NSAttributedStringKey.foregroundColor: l.valueTextColor]) } } } diff --git a/Source/Charts/Renderers/YAxisRendererRadarChart.swift b/Source/Charts/Renderers/YAxisRendererRadarChart.swift index fc9f8da28b..cab45f7125 100644 --- a/Source/Charts/Renderers/YAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererRadarChart.swift @@ -196,8 +196,8 @@ open class YAxisRendererRadarChart: YAxisRenderer point: CGPoint(x: p.x + 10.0, y: p.y - labelLineHeight), align: .left, attributes: [ - NSAttributedStringKey.font.rawValue: labelFont, - NSAttributedStringKey.foregroundColor.rawValue: labelTextColor + NSAttributedStringKey.font: labelFont, + NSAttributedStringKey.foregroundColor: labelTextColor ]) } } diff --git a/Source/Charts/Utils/ChartUtils.swift b/Source/Charts/Utils/ChartUtils.swift index c21fdafaaa..21601a7030 100755 --- a/Source/Charts/Utils/ChartUtils.swift +++ b/Source/Charts/Utils/ChartUtils.swift @@ -123,7 +123,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - open class func drawText(context: CGContext, text: String, point: CGPoint, align: NSTextAlignment, attributes: [String : AnyObject]?) + open class func drawText(context: CGContext, text: String, point: CGPoint, align: NSTextAlignment, attributes: [NSAttributedStringKey : Any]?) { var point = point @@ -143,7 +143,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - open class func drawText(context: CGContext, text: String, point: CGPoint, attributes: [String : AnyObject]?, anchor: CGPoint, angleRadians: CGFloat) + open class func drawText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedStringKey : Any]?, anchor: CGPoint, angleRadians: CGFloat) { var drawOffset = CGPoint() @@ -195,7 +195,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - internal class func drawMultilineText(context: CGContext, text: String, knownTextSize: CGSize, point: CGPoint, attributes: [String : AnyObject]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) + internal class func drawMultilineText(context: CGContext, text: String, knownTextSize: CGSize, point: CGPoint, attributes: [NSAttributedStringKey : Any]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) { var rect = CGRect(origin: CGPoint(), size: knownTextSize) @@ -243,7 +243,7 @@ open class ChartUtils NSUIGraphicsPopContext() } - internal class func drawMultilineText(context: CGContext, text: String, point: CGPoint, attributes: [String : AnyObject]?, constrainedToSize: CGSize, anchor: CGPoint, angleRadians: CGFloat) + internal class func drawMultilineText(context: CGContext, text: String, point: CGPoint, attributes: [NSAttributedStringKey : 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 6fd7c8a366..d574402898 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -222,7 +222,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple public typealias NSUIImage = NSImage public typealias NSUIScrollView = NSScrollView public typealias NSUIGestureRecognizer = NSGestureRecognizer - public typealias NSUIGestureRecognizerState = NSGestureRecognizerState + public typealias NSUIGestureRecognizerState = NSGestureRecognizer.State public typealias NSUIGestureRecognizerDelegate = NSGestureRecognizerDelegate public typealias NSUITapGestureRecognizer = NSClickGestureRecognizer public typealias NSUIPanGestureRecognizer = NSPanGestureRecognizer @@ -522,7 +522,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple // iOS: size(attributes: ...), OSX: size(withAttributes: ...) // Both are translated into sizeWithAttributes: on ObjC. So conflict... @nonobjc - func size(attributes attrs: [String : Any]? = nil) -> NSSize + func size(attributes attrs: [NSAttributedStringKey : Any]? = nil) -> NSSize { return size(withAttributes: attrs) } @@ -530,14 +530,14 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple func NSUIGraphicsGetCurrentContext() -> CGContext? { - return NSGraphicsContext.current()?.cgContext + return NSGraphicsContext.current?.cgContext } func NSUIGraphicsPushContext(_ context: CGContext) { let cx = NSGraphicsContext(cgContext: context, flipped: true) NSGraphicsContext.saveGraphicsState() - NSGraphicsContext.setCurrent(cx) + NSGraphicsContext.current = cx } func NSUIGraphicsPopContext() @@ -550,7 +550,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple image.lockFocus() let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) image.unlockFocus() - return rep?.representation(using: .PNG, properties: [:]) + return rep?.representation(using: .png, properties: [:]) } func NSUIImageJPEGRepresentation(_ image: NSUIImage, _ quality: CGFloat = 0.9) -> Data? @@ -558,7 +558,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple image.lockFocus() let rep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height)) image.unlockFocus() - return rep?.representation(using: .JPEG, properties: [NSImageCompressionFactor: quality]) + return rep?.representation(using: .jpeg, properties: [NSBitmapImageRep.PropertyKey.compressionFactor: quality]) } private var imageContextStack: [CGFloat] = [] @@ -568,7 +568,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple var scale = scale if scale == 0.0 { - scale = NSScreen.main()?.backingScaleFactor ?? 1.0 + scale = NSScreen.main?.backingScaleFactor ?? 1.0 } let width = Int(size.width * scale) @@ -618,7 +618,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple func NSUIMainScreen() -> NSUIScreen? { - return NSUIScreen.main() + return NSUIScreen.main } #endif