Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly subclass XAxis? #4155

Closed
bardonadam opened this issue Sep 24, 2019 · 2 comments
Closed

How to properly subclass XAxis? #4155

bardonadam opened this issue Sep 24, 2019 · 2 comments

Comments

@bardonadam
Copy link

bardonadam commented Sep 24, 2019

I made a subclass of the XAxis:

class CustomXAxis: XAxis {
// empty, no custom implementation yet
}

And assigned it to my renderer:

let xAxis = CustomXAxis()
barChart.xAxisRenderer = CustomXAxisRenderer(viewPortHandler: barChart.viewPortHandler, xAxis: xAxis, transformer: barChart.getTransformer(forAxis: .left))

The problem is that my renderer overrides computeSize() function, but it has no/incorrect effect on xAxis height. When I initialize my renderer with barChart.xAxis instead of my custom one, it works as expected.

Is there anything left to do when subclassing XAxis?

@LeeCenY
Copy link

LeeCenY commented Oct 11, 2019

OC project, ask how to inherit xAxisRenderer
Error message: Cannot subclass a class that was declared with the 'objc_subclassing_restricted' attribute

@liuxuan30
Copy link
Member

liuxuan30 commented Oct 29, 2019

@objc(ChartXAxis)
open class XAxis: AxisBase
{

you should be clear to subclass it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants