You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to subclass HorizontalBarChartRenderer so that I can change implementation of drawDataSet(...). 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 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 the renderer like this: self.horizontalBarView.renderer = CustomRenderer(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?
The text was updated successfully, but these errors were encountered:
Yes, that is correct. But I don't get it why. If my CustomRenderer is basically just a copy of HorizontalBarChartRenderer(I haven't changed the implementation of the methods that I've overridden), so I'd assume that if HorizontalBarChartRenderer works, then changing it to CustomRenderer at the same place should work as well.
I finally know what was the issue, my subclass didn't override drawValues() method, as it wasn't explicit that it is needed. Moreover, this method is accessing variable shouldDrawValues which is internal and therefor can't be accessed outside the module. I commented out the part where it's used for now, but I'll have to somehow mimic it on my own.
I need to subclass HorizontalBarChartRenderer so that I can change implementation of
drawDataSet(...)
. So I created my custom renderer, but because of access control and because I'm using Cocoapods I had to override little more than justdrawDataSet
:I didn't change anything yet, above methods were just copied from
HorizontalBarChartRenderer
, and I set the renderer like this:self.horizontalBarView.renderer = CustomRenderer(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
atBarCharRenderer'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?
The text was updated successfully, but these errors were encountered: