-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Module is not extensible #357
Comments
"protected" methods are not available in Swift. For some reason Apple think
that it's not a use case...
Maybe a post on the appropriate Swift forum will change something...
|
I would suggest maybe writing an extension to |
You cannot override methods from extensions:
|
@martinnormark it is not an extension but a module... |
Yes, I was just replying to @petester42 's suggestion. |
There is a distinction though. If the property or function comes from the subclass then its fine.
I thought it might work since |
@danielgindi I believe this kind of issue could be solved if the renderers were protocol oriented and not subclasses. Then the charts could then take any object that adheres to lets say |
@petester42 Should work it seems. Then you only need to subclass the |
I think, maybe, we should try turning into |
I think that maybe things that are "protected" in the Java counterpart, should be public here, but prefixed with an underscore, so the developer/user can know whether he/she is supposed to access it or not. |
+1 I am working on a custom renderer but I cannot access the animator |
+1 Trying to add a gradient to the Cubic Line chart, can't get at the drawCubicFill method. Means i'm going to have to throw anyway cocoapods and import manually so I can modify it. |
Bumped again. I need to assign a custom highlighter to a custom chart, derived from bubble chart. And cant access |
Yes this will be address soon On Thu, Nov 12, 2015 at 11:40 AM, Rajesh Sharma notifications@github.com
|
👍 |
how do you suggest I do it for now? |
@broncha you're going to need to bring the source code into your project and modify the files directly. |
@danielgindi perhaps take a loot at the Protocol-Oriented Programming video from WWDC 2015 for inspiration here. |
The more I look at this library from a Swift/extensibility perspective, the more I realize that what I am asking is probably out of the scope of what this library intends, since it is supposed to be a direct port of a Java counterpart. |
As long as the API for the library remains similar to the Java version then it would be fine. Changes also go both ways. If you add something good to iOS charts then there is is a good chance it makes its way to Java version and vice versa. Don't let it discourage you from implementing something cool for this library. You can try to give protocol oriented programming for the ChartHighlighter a shot and see if it's feasible. |
About the custom highlighter part, I had to copy the entire |
@broncha It seems you could replaced the |
@petester42 took your advice. Please let me know if I went in the right direction with that. The sample app just works without any modifications. Unit tests don't seem to cover that part, but they all passed. |
another quesiton, shall we make initialize() to public rather than internal? I saw some people want to replace the renderer, but they cannot override initialize() outside of the library:http://stackoverflow.com/questions/33994223/fetching-current-x-position-when-graph-is-set-to-scroll-in-ios-charts/34011274?noredirect=1#comment55831925_34011274 |
That's exactly what I intend to do. Subclass an existing renderer, and override methods. Then pass that renderer to the chart view. Perhaps you could define your own renderer by setting a public property instead? |
I am using the source files, so have no trouble of override internal stuff. But seems lots of people are sub classing outside of the library. |
Moving to protocol oriented - will cause problem with keeping cross-platform API. Instead, everything in the renderers is now completely public :-) |
Excellent 👍 Any idea when you'll cut a new release? |
Probably around a day. Just checking for any incompatibilities that I can find with the Android API, as this is the time to fix them, along with the other structural changes that were done (and also for critical bugs that must be included in this version) |
@martinnormark how do you pass the your custom renderer to the chartView? |
I do not have a suggested solution for this issue, but the Swift module is not nearly as extensible as the Java counterpart. In Java, you can create a subclass of a chart renderer and take advantage of internal/protected methods & properties to create a custom chart renderer. This does not appear to be the case with the Swift module.
I was trying to create a bar chart with rounded corners on the bars. I needed to subclass BarChartRenderer, but was unable to do so without moving the ios-charts source code into my app's module.
Is there a way to accomplish a similar level of API-parity with the Java counterpart while at the same time allowing for extensibility? Perhaps take advantage of protocols or something.
The text was updated successfully, but these errors were encountered: