         }
         
         
-        
-        
         for bar in newVisibleBars {
             
             let barHeight = maxBarValue > 0 ? bar.totalValue() / maxBarValue * height : 0.0

            
            let barFrame = CGRect(x: xPosition, y: height - barHeight, width: bar.width, height: barHeight)
            
//            let stackedBarView = StackedBarView(frame: barFrame, segments: bar.segments)
            let stackedBarView: StackedBarView
            if let existingStackedBarView = barToBarViews[bar] {
                stackedBarView = existingStackedBarView
                stackedBarView.frame = barFrame
//                stackedBarView.segments = bar.segments
            } else {
                stackedBarView = dequeueStackedBarWithFrame(barFrame, segments: bar.segments)
                barToBarViews[bar] = stackedBarView
                addSubview(stackedBarView)
            }
//            if stackedBarView.superview == nil {
//                addSubview(stackedBarView)
//            }
            
            stackedBarView.cornerRadius = barCornerRadius
        }

    }
    
    private func dequeueStackedBarWithFrame(frame: CGRect, segments: [BarSegment]) -> StackedBarView {
        // This should probably sync?
        
        let stackedBarView : StackedBarView

            stackedBarView = stackedBarViewQueue.removeFirst()
        } else {
            stackedBarView = StackedBarView()
            stackedBarView.cornerRadius = barCornerRadius
            
        }
        return stackedBarView
        
    }
    
    private func visibleBarsForOffset(currentOffset: CGFloat) -> [Bar] {

        let barWidth = bars[0].width
        let minVisibleXAxisPosition = 0 + currentOffset - (barWidth / 2)
        
        let maxVisibleXAxisPosition = bounds.size.width + currentOffset + (barWidth / 2)
        let newBars = bars.filter {
            return $0.xAxisPosition > minVisibleXAxisPosition && $0.xAxisPosition < maxVisibleXAxisPosition
        }
        
        
        return Array(newBars)
    }
}