I'm using iOS-Charts library, and I need to subclass HorizontalBarChartRenderer
so that I can change implementation of drawDataSet(...)
. This should be possible as stated before, like in this answer.
So I created my custom renderer, but because of access control and because I'm using Cocoapods I had to override little more than just drawDataSet
:
- fileprivate class Buffer
- fileprivate var _buffers = Buffer
- fileprivate func prepareBuffer(dataSet: IBarChartDataSet, index: Int)
- fileprivate var _barShadowRectBuffer: CGRect = CGRect() open override
- open override func drawDataSet(context: CGContext, dataSet: IBarChartDataSet, index: Int)
I didn't change anything yet, above methods were just copied from HorizontalBarChartRenderer
, and I set renderer like this:
self.horizontalBarView.renderer = HorizontalBarStackRenderer(dataProvider: self.horizontalBarView, animator: self.horizontalBarView.chartAnimator, viewPortHandler: self.horizontalBarView.viewPortHandler).
When I try to run it, I get fatal error: Index out of range
at BarCharRenderer's drawValues()
:
let buffer = _buffers[dataSetIndex]
When I tried to set renderer to standard HorizontalBarChartRenderer
the same way:
self.horizontalBarView.renderer = HorizontalBarChartRenderer(dataProvider: self.horizontalBarView, animator: self.horizontalBarView.chartAnimator, viewPortHandler: self.horizontalBarView.viewPortHandler)
everything works fine. Am I missing something?