Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxisBase Value Formatter #3105

Closed
jjatie opened this issue Dec 14, 2017 · 1 comment
Closed

AxisBase Value Formatter #3105

jjatie opened this issue Dec 14, 2017 · 1 comment

Comments

@jjatie
Copy link
Collaborator

jjatie commented Dec 14, 2017

valueFormatter is implemented as so:

    @objc open var valueFormatter: IAxisValueFormatter?
    {
        get
        {
            if _axisValueFormatter is DefaultAxisValueFormatter,
                (_axisValueFormatter as! DefaultAxisValueFormatter).hasAutoDecimals,
                (_axisValueFormatter as! DefaultAxisValueFormatter).decimals != decimals
            {
                _axisValueFormatter = DefaultAxisValueFormatter(decimals: decimals)
            }
            
            return _axisValueFormatter
        }
        set
        {
            _axisValueFormatter = newValue ?? DefaultAxisValueFormatter(decimals: decimals)
        }
    }

If we allow custom formatters, then why do we reset the formatter if it's using a modified DefaultAxisValueFormatter? Any subclasses of DefaultAxisValueFormatter would also trigger this reset. I feel we should either not allow custom formatters, or provide an implementation like this:

    @objc open var valueFormatter: IAxisValueFormatter?
    {
        get { return _axisValueFormatter }
        set { _axisValueFormatter = newValue ?? DefaultAxisValueFormatter(decimals: decimals) }
    }
@liuxuan30
Copy link
Member

I guess because DefaultAxisValueFormatter is kind of a demo formatter, or default one. People who want to customize usually does not subclass DefaultAxisValueFormatter?
allowing custom formatters is fine, since it's just a protocol.
Anyway, what confuses me now is the getter struggling with decimals, which I don't remember why..
if changing it won't trigger any CI failures, I think it's fine to go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants