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

ios-charts different plotting activity than MKAndroidChart #276

Closed
nlabhart opened this issue Aug 5, 2015 · 14 comments
Closed

ios-charts different plotting activity than MKAndroidChart #276

nlabhart opened this issue Aug 5, 2015 · 14 comments

Comments

@nlabhart
Copy link

nlabhart commented Aug 5, 2015

Please see the attached screenshots for a visual of what is happening. The data set is coming back the from the same source, and is the same data. The data is plotting correctly on the Android implementation (MKAndroidChart), but is not plotting correctly using ios-charts. Is there an obviously setting or view property that I did not set? If you need to see code, I can certainly post it.

ANDROID (Correct Version)
android

IOS (Incorrect plotting)
ios

@liuxuan30
Copy link
Member

First of all, your data seems not the same, android data range is like [70K, 110K], but iOS version is like [90K,110K]

Another is its origin point is higher than android. Double check your chart view's frame on iOS.

@nlabhart
Copy link
Author

nlabhart commented Aug 5, 2015

@liuxuan30 the data I am pulling matches what is in Android (70K, 110K).
This was the first indicator that there was a problem. Also, the frame
doesn't change. It is set in a Xib, and loaded without changing the frame.
However, there is auto layout constraints attached to it. Could this cause
a problem?

@liuxuan30
Copy link
Member

It should never be the case that if you feed the data in range [70K,110K] and it draws at the wrong position like [90K,110K], at least not on my side... It's a serious bug and I just cannot believe it right now. You might need to provide the dataSet code and we can try.

For the frame, you can check and compare before/after the autolayout engine calculate the frame. I would suggest start from debugging the frame.

What you can try is after the autolayout engine finalized the frame, you start creating the dataSet and feed the chart.

I just take a look at the ChartsDemo, and it also uses autolayout. Seems putting the code in viewDidLoad is also fine. Anyway, you have to debug it more

@danielgindi
Copy link
Collaborator

To me it seems that your problem is the NSNumberFormatter is not configured similarly.

@danielgindi
Copy link
Collaborator

You may also want to check if your auto-layout constraints stick to margins or not. Because those "margins" can confuse and cause you to add extra spacing - or have negative extra spacing.

@nlabhart
Copy link
Author

nlabhart commented Aug 5, 2015

The NumberFormatter for the Y Axis is a separate issue. I'll check the
auto-layout constraints to see if that is what is causing the problem. And
I'll check the frame before and after the constraints are applied - I
suspect that is where the issue is, but I'm not sure how to fix it.

@liuxuan30
Copy link
Member

@nlabhart I also guess it's autolayout problem, yesterday I met one. Configuring chart view in viewDidLoad and viewDidAppear has slight difference. The one in viewDidAppear is not correct. But it's not my code, so I have to wait for other people to fix.

@nlabhart
Copy link
Author

nlabhart commented Aug 6, 2015

Xuan - is there a function similar to the invalidate() function on
MKAndroidChart? Is the only option setNeedsDisplay?

@danielgindi
Copy link
Collaborator

setNeedsDisplay IS invalidate()

‏בתאריך יום חמישי, 6 באוגוסט 2015, Noah Labhart [email protected]
כתב:

Xuan - is there a function similar to the invalidate() function on
MKAndroidChart? Is the only option setNeedsDisplay?

On Wed, Aug 5, 2015 at 8:45 PM, Xuan <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

@nlabhart https://github.com/nlabhart I also guess it's autolayout
problem, yesterday I met one. Configuring chart view in viewDidLoad and
viewDidAppear has slight different. The one in viewDidAppear is not
correct. But it it's not my code, so I have to wait for other people to
fix.


Reply to this email directly or view it on GitHub
<
#276 (comment)

.

Sincerely,

Noah Labhart
[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');
817-988-5253


Reply to this email directly or view it on GitHub
#276 (comment)
.

@nlabhart
Copy link
Author

nlabhart commented Aug 6, 2015

That is good to know!

What I have found out is that changing the option setZeroEnabled for the
yAxis only changes the yAxis, and not the data. So I need to redraw the
data somehow. Perhaps setNeedsDisplay is the answer.

@danielgindi
Copy link
Collaborator

Yes it is. In most functions that work on the data, the chart can't know
about the changes, so you have to tell it.
Sometimes it involves calling "notifyDataSetChanged", sometimes a render is
enough

‏בתאריך יום חמישי, 6 באוגוסט 2015, Noah Labhart [email protected]
כתב:

That is good to know!

What I have found out is that changing the option setZeroEnabled for the
yAxis only changes the yAxis, and not the data. So I need to redraw the
data somehow. Perhaps setNeedsDisplay is the answer.

On Thu, Aug 6, 2015 at 7:03 AM, Daniel Cohen Gindi <
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');

wrote:

setNeedsDisplay IS invalidate()

‏בתאריך יום חמישי, 6 באוגוסט 2015, Noah Labhart <
[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');>
כתב:

Xuan - is there a function similar to the invalidate() function on
MKAndroidChart? Is the only option setNeedsDisplay?

On Wed, Aug 5, 2015 at 8:45 PM, Xuan <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');
<javascript:_e(%7B%7D,'cvml','[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');');>> wrote:

@nlabhart https://github.com/nlabhart I also guess it's autolayout
problem, yesterday I met one. Configuring chart view in viewDidLoad
and
viewDidAppear has slight different. The one in viewDidAppear is not
correct. But it it's not my code, so I have to wait for other people
to
fix.


Reply to this email directly or view it on GitHub
<

#276 (comment)

.

Sincerely,

Noah Labhart
[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');
<javascript:_e(%7B%7D,'cvml','[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');');>
817-988-5253


Reply to this email directly or view it on GitHub
<

#276 (comment)

.


Reply to this email directly or view it on GitHub
<
#276 (comment)

.

Sincerely,

Noah Labhart
[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');
817-988-5253


Reply to this email directly or view it on GitHub
#276 (comment)
.

@nlabhart
Copy link
Author

nlabhart commented Aug 6, 2015

Figured it out, without setNeedsDisplay or notifyDataHasChanged.

There are two Y axis's in the LineChart I am using - leftAxis and
rightAxis. I had disabled the rightAxis from starting at zero
(startAtZeroEnabled = NO), and disabled the leftAxis entirely (enabled =
NO). However, I tried to set the startAtZeroEnabled on BOTH the left and
right axis - and it started charting properly. So despite the leftAxis
being disabled, the startAtZeroEnabled setting applied.

Thanks for the help!

@liuxuan30
Copy link
Member

Have you set your dataSet.axisDependency accordingly? By default it's left. but if you disable leftAxis and enable rightAxis, it should render wrongly I think. startAtZeroEnabled will only affect how the axis range is calculated. if you only have positive data, it's ok to leave it as 'YES' on both axis.

BTW, be careful it you have negative values and disabled startAtZeroEnabled, because I think current calcuation for axis range has bug when dealing with small negative values. Check #166, PR #207, though it's for radar chart. They share the same axis range calcuation in computeAxisValues.

@nlabhart
Copy link
Author

Hi @danielgindi would it be possible for you to remove my email address references from your comments? :)

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