             for i in barData.indices {
                 let set = barData[i] as! BarChartDataSet
                 let size = set.count * (set.isStacked ? set.stackSize : 1)
-                if _buffers[i].rects.count != size {
-                    _buffers[i].rects = [CGRect](repeating: CGRect(), count: size)
+                if _buffers[i].count != size {
+                    _buffers[i] = [CGRect](repeating: CGRect(), count: size)
                 }
             }
         } else {

        let isStacked = dataSet.isStacked
        let stackSize = isStacked ? dataSet.stackSize : 1

        for j in buffer.rects.indices {
            let barRect = buffer.rects[j]

            if !viewPortHandler.isInBoundsTop(barRect.origin.y + barRect.size.height) {
                break
            }

                for index in 0 ..< Int(ceil(Double(dataSet.count) * animator.phaseX)) {
                    guard let e = dataSet[index] as? BarChartDataEntry else { continue }

                    let rect = buffer[bufferIndex]

                    let vals = e.yValues

