From c9cb9e21d2cc40032f76cba422b2af1a311f3287 Mon Sep 17 00:00:00 2001 From: Xuan Liu Date: Mon, 30 Mar 2020 10:06:55 +0800 Subject: [PATCH] use enum orientation for widthLarger --- Source/Charts/Charts/PieChartView.swift | 2 +- Source/Charts/Utils/Platform.swift | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Charts/Charts/PieChartView.swift b/Source/Charts/Charts/PieChartView.swift index 170d07d716..de9b8dbe59 100644 --- a/Source/Charts/Charts/PieChartView.swift +++ b/Source/Charts/Charts/PieChartView.swift @@ -132,7 +132,7 @@ open class PieChartView: PieRadarChartViewBase /// if width is larger than height private var widthLarger: Bool { - return _viewPortHandler.contentRect.size.width > _viewPortHandler.contentRect.size.height + return _viewPortHandler.contentRect.orientation == .landscape } /// adjusted radius. Use diameter when it's half pie and width is larger diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index 2eb4efd42e..ced6884dde 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -166,6 +166,21 @@ extension UIScreen } } +enum Orientation +{ + case portrait, landscape +} + +extension CGSize +{ + var orientation: Orientation { return width > height ? .landscape : .portrait } +} + +extension CGRect +{ + var orientation: Orientation { size.orientation } +} + func NSUIGraphicsGetCurrentContext() -> CGContext? { return UIGraphicsGetCurrentContext()