From 13094be1f0286c5a4de087db9ef48970bb30d934 Mon Sep 17 00:00:00 2001 From: Andy Martushev Date: Fri, 28 Jun 2019 15:11:24 -0600 Subject: [PATCH 1/2] move isDrawCirclesEnabled check further up in code to avoid creating accessibility labels that will never appear anyway. Reduces CPU significantly for larger datasets. --- Source/Charts/Renderers/LineChartRenderer.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index eedd92de91..b43e4b0f9c 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -601,6 +601,14 @@ open class LineChartRenderer: LineRadarRenderer continue } + + // Skip Circles and Accessibility if not enabled. + //reduces CPU significantly if not needed + if !dataSet.isDrawCirclesEnabled + { + continue + } + // Accessibility element geometry let scaleFactor: CGFloat = 3 let accessibilityRect = CGRect(x: pt.x - (scaleFactor * circleRadius), @@ -621,11 +629,6 @@ open class LineChartRenderer: LineRadarRenderer accessibilityOrderedElements[i].append(element) } - if !dataSet.isDrawCirclesEnabled - { - continue - } - context.setFillColor(dataSet.getCircleColor(atIndex: j)!.cgColor) rect.origin.x = pt.x - circleRadius From 28e066197896205dee2270ac43a5c5ce2890d4b8 Mon Sep 17 00:00:00 2001 From: Xuan Date: Mon, 11 Nov 2019 09:46:17 +0800 Subject: [PATCH 2/2] Update LineChartRenderer.swift --- Source/Charts/Renderers/LineChartRenderer.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index b43e4b0f9c..9216395e2c 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -602,8 +602,8 @@ open class LineChartRenderer: LineRadarRenderer } - // Skip Circles and Accessibility if not enabled. - //reduces CPU significantly if not needed + // Skip Circles and Accessibility if not enabled, + // reduces CPU significantly if not needed if !dataSet.isDrawCirclesEnabled { continue