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

xMin, xMax, yMin, yMax not recalculated to zero on .clear() #2822

Closed
illysky opened this issue Sep 24, 2017 · 1 comment
Closed

xMin, xMax, yMin, yMax not recalculated to zero on .clear() #2822

illysky opened this issue Sep 24, 2017 · 1 comment

Comments

@illysky
Copy link

illysky commented Sep 24, 2017

When dataset.clear() is called, calcMinMax is skipped when the values count is zero,
there xMin, xMax, yMin, yMax stay as they are and my Y- Axis doesn't scale to the new minimum entries value.

Get an exception when I force the calcMinMax despite value count being zero.

Workaround, I manually clear xMin, xMax, yMin, yMax just after calcMinMax in the .clear() function.

@liuxuan30
Copy link
Member

liuxuan30 commented Sep 26, 2017

    open override func calcMinMax()
    {
        if _values.count == 0
        {
            return
        }
        
        _yMax = -Double.greatestFiniteMagnitude
        _yMin = Double.greatestFiniteMagnitude
        _xMax = -Double.greatestFiniteMagnitude
        _xMin = Double.greatestFiniteMagnitude
        
        for e in _values
        {
            calcMinMax(entry: e)
        }
    }

if continue, those max and min are just -INF or INF, which are also problematic. If you cleared them up, no data left, how does y axis scale to the "new minimum entries value" then? unless you set outside, but it has nothing to do with the data then. Why clear?

I would say if you have new data, just feed and call notifyDataSetChanged() so it will recalculate everything.

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