ChartsOrg / ChartsOrg/Charts

Cannot find interface declaration for 'ChartXAxisRenderer' when subclassing XAxisRenderer

Open
#4,378 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

> ℹ Please fill out this template when filing an issue.
> All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info.
>
> Per our [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md), we use GitHub for
> bugs and feature requests, not general support. Other issues should be opened on Stack Overflow with the tag [`ios-charts`.](https://stackoverflow.com/questions/tagged/ios-charts)
>
> Please remove this line and everything above it before submitting.

* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

I have added Charts to an iOS swift project with SPM. I am able to create charts without any issues. I want to subclass the XAxisRenderer class to customise the limit line label like shown below.

```
class CustomRenderer: XAxisRenderer {
override func renderLimitLineLabel(context: CGContext, limitLine: ChartLimitLine, position: CGPoint, yOffset: CGFloat) {
// My changes
ChartUtils.drawText(
context: context,
text: label,
point: point,
align: align,
attributes: attributes
)
}
}

```

So that I can then apply it to my LineChart like:
```
self.lineChart.xAxisRenderer = CustomRenderer(
viewPortHandler: self.lineChart.viewPortHandler,
xAxis: self.lineChart.xAxis,
transformer: self.lineChart.getTransformer(forAxis: .left)
)
```

## What did you expect to happen?

I can subclass the XAxisRenderer and pass it to my chart. I do have a bridging header file because I have some objective-c view controllers in the swift project. I have also marked "Always Embed Swift Standard Libraries" under build options. I researched and didn't see any issues like the one I am facing. I have a feeling it's something I missed but I am unable to find the cause.

## What happened instead?

However subclassing causes the build to fail with the following error...
![Screenshot 2020-05-26 at 14 54 28](https://user-images.githubusercontent.com/8417115/82897896-099ab780-9f61-11ea-87b3-a288254dc2a7.png)
![Screenshot 2020-05-26 at 14 56 39](https://user-images.githubusercontent.com/8417115/82898016-3e0e7380-9f61-11ea-8e90-91ecc6fff0ab.png)

## Charts Environment

**Charts version/Branch/Commit Number:** 3.5.0
**Xcode version:** Version 11.5 (11E608c)
**Swift version:** 5
**Platform(s) running Charts:** iOS
**macOS version running Xcode:** -

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.