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

Issue concerning layers (I think) #35

Closed
ghost opened this issue Aug 30, 2015 · 7 comments
Closed

Issue concerning layers (I think) #35

ghost opened this issue Aug 30, 2015 · 7 comments

Comments

@ghost
Copy link

ghost commented Aug 30, 2015

This issue is more a problem of mine I think, but after many spent time i cannot still figure it out...

Why does this code (rougthly the same as the tracker example one) doesn't display anything else than the curve?

http://imgur.com/Gca5Bxf

The datepicker bug is something else, sorry for it. but only the red plot appears. (i tryed on other circumstances before with full view on the curve)

http://imgur.com/UnmfVaO

It may be trivial but I can't find a logical explanation/solution...

@ivnsch
Copy link
Owner

ivnsch commented Aug 30, 2015

Can you please provide a self contained example (as text, maybe as a gist)? Don't see the problem in your code. Are you working with the example's code or are there other differences? If it's drawing the line correctly but not the axes it's likely something with the view, not the model data.

@ghost
Copy link
Author

ghost commented Aug 31, 2015

Here a pastebin, and yhea that's what i though with the view. How can the view influence this, do you have more details? http://pastebin.com/V9zKnL7N

It's not the direct example, but it's really close, and i don't think there are any big errors, must be the view. Is it possible to resize the graphic so it doesnt take full view space? Or may it be what precisely make it crash?

Thanks for your answer

Edit: made some cleaning: Here is the code snippet generated graph (with static data, not my json points), inside an empty view. Nothing fancy :/ but still fail. http://imgur.com/PKvmzaL
And reducing the complexity possibilities, the problem is the same with a simpler chart:
http://pastebin.com/p55VPQ6r result http://imgur.com/bPDMScz

Edit 2: tried again everything from scratch, with fresh new view, the basic code, impossible to have anything else that the plot lines :/ I don't get it, must be on my side but... What do you have with the previous code?

I am using the NON-swift2.0 version

@ivnsch
Copy link
Owner

ivnsch commented Aug 31, 2015

The snippets are still missing the context... Is your view's size already computed when you call getChartFrame? Somebody who was using autolayout had similar issues, see #30, here the solution: https://gist.github.com/i-schuetz/f6e285eb0c86bb831510

Otherwise start with one of the examples and edit it until you can reproduce it, so we know what exactly is causing the issue. If nothing helps please either post the full code, or upload somewhere a project where the issue is reproduced and I'll take a look.

@ghost
Copy link
Author

ghost commented Aug 31, 2015

I think it's on my side, let me spend more time on it before sharing it. Thanks a lot anyway. I keep this open and keep you updated.

And yhea my view is already computed, I mean i have a view with 2 date pickers, and when the user pick the 2 dates then the chart is rendered

ps: getChartView is the same as in your examples:

func getChartFrame(containerBounds: CGRect) -> CGRect { return CGRectMake(0, 70, containerBounds.size.width, containerBounds.size.height - 70) }

@ghost
Copy link
Author

ghost commented Sep 1, 2015

I am becoming crazy... I don't understand why it won't work. I can use the simplest example, yet I never saw any x or y axis bars. My project is on github, files PowermonitorIOS/viewcontrollers/ChartVC.swift, if you wanna check. I reinstalled SwiftCharts, I deleted my files and recreated them. I don't know what to do

EDIT: Found IT! I didn't used
self.chart = chart and the var chart

Can you explain me how it could have such impact? Is it keeping track of the layers?

@ghost ghost closed this as completed Sep 1, 2015
@ivnsch
Copy link
Owner

ivnsch commented Sep 1, 2015

The chart has to be referenced, otherwise it's released, and when ChartBaseView calls drawRect on it (which is used to draw the axes) the reference is nil. ChartBaseView doesn't have a strong reference to Chart because otherwise it would cause a reference cycle...

This is also why there's an "arc" comment next to the chart declaration in the examples.

This is admittedly a bit cumbersome, may change the architecture in the future to prevent it. A possibility would be to implement the chart directly as view, which is always retained. Right now I'm not sure though if this works nicely with the way the library is designed.

Sorry for not thinking about this before, I actually also had this issue before adding the instance variables, but totally forgot.

@ghost
Copy link
Author

ghost commented Sep 1, 2015

It's totally fine, you just share you API and I should check everything more carefully. Anyway, thanks for SwiftCharts! It's great

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

No branches or pull requests

1 participant