MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

LineDataSet.clear() does not clear x/y min/max

Open zkdzegede opened this issue 9 years ago • 4 comments

For the LineDataSet, the mValues is cleared and then calcMinMax is called through notifyDataSetChanged.

However if the mValues is size 0, the min/max is not updated....

public void clear() {
        this.mValues.clear();
        this.notifyDataSetChanged();
    }

public void notifyDataSetChanged() {
        this.calcMinMax();
    }

@Override
    public void calcMinMax() {
        if(this.mValues != null && !this.mValues.isEmpty()) {
            this.mYMax = -3.4028235E38F;
            this.mYMin = 3.4028235E38F;
            this.mXMax = -3.4028235E38F;
            this.mXMin = 3.4028235E38F;
            Iterator var1 = this.mValues.iterator();

            while(var1.hasNext()) {
                Entry e = (Entry)var1.next();
                this.calcMinMax(e);
            }

        }
    }

zkdzegede avatar Nov 14 '16 11:11 zkdzegede

this.calcMinMax(); is not worked.

denisagt avatar Feb 26 '25 19:02 denisagt

.getXMax() do not update

denisagt avatar Feb 26 '25 19:02 denisagt

becouse after .clear mValues=0!

denisagt avatar Feb 26 '25 19:02 denisagt

only this-worked:

    set1.clear();
    set1.addEntry(new Entry(0, 0));
    set1.notifyDataSetChanged();

denisagt avatar Feb 26 '25 19:02 denisagt