From ff7a2fc0d191a8d63c82ddea2b3d09146fa78c32 Mon Sep 17 00:00:00 2001 From: Grant Kamin Date: Mon, 11 May 2020 07:55:09 -0500 Subject: [PATCH] Fix AxisBase Formatter Getter (Fixes #4365) Fixes issue where if you overrode the formatter it didn't matter because a new one would just replace it. --- Source/Charts/Components/AxisBase.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Charts/Components/AxisBase.swift b/Source/Charts/Components/AxisBase.swift index d5b653943e..0b59628d4f 100644 --- a/Source/Charts/Components/AxisBase.swift +++ b/Source/Charts/Components/AxisBase.swift @@ -166,14 +166,17 @@ open class AxisBase: ComponentBase { get { - if _axisValueFormatter == nil || - (_axisValueFormatter is DefaultAxisValueFormatter && - (_axisValueFormatter as! DefaultAxisValueFormatter).hasAutoDecimals && - (_axisValueFormatter as! DefaultAxisValueFormatter).decimals != decimals) + if _axisValueFormatter == nil { _axisValueFormatter = DefaultAxisValueFormatter(decimals: decimals) } - + else if _axisValueFormatter is DefaultAxisValueFormatter && + (_axisValueFormatter as! DefaultAxisValueFormatter).hasAutoDecimals && + (_axisValueFormatter as! DefaultAxisValueFormatter).decimals != decimals + { + (self._axisValueFormatter as! DefaultAxisValueFormatter).decimals = self.decimals + } + return _axisValueFormatter } set