-
-
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
[Charts 3.0] Issue with centerAxisLabelsEnabled #1566
Comments
where do you get |
BTW, I checked combined chart in ChartsDemo on master; it works fine with |
@liuxuan30 I got the error from Oh then how would I center the labels? |
I checked combined chart in ChartsDemo on master; it works fine with centerAxisLabelsEnabled turned on. Looks like you did not setup correctly; check the demo. |
|
- (NSString *)stringForValue:(double)value
axis:(ChartAxisBase *)axis
{
return months[(int)value % months.count];
} this is now Demo passes the string to x axis. If you seeing out of range.. maybe time to use mod. I do see you use |
@liuxuan30 Thanks a lot for looking into the issue. This is how I'm setting up the chartView
I just logged the ChartFormatter class and this is what I got :
I've no idea why is this getting called so many times when I tried with |
@liuxuan30 I think the Because from
|
Phew. Found the issue. My bad. I was not setting the |
Just want to share my experience, I solved this issue using a dynamic granularity, make chart adjust while zooming Important do not force labelCount First I have many datasets, so I group datasets values using
Adjust granularity base on how many columns you want to see Then set data Then I use a custom Formatter to calculate label to be shown
Set the custom formatter
Try and let me know. Happy coding! |
@samueleperricone computing granularity worked. Cheers :) |
computing granularity as done by @codingspark worked for me. chart.xAxis.granularity = chart.xAxis.axisMaximum / Double(labels.count) |
I've used a
CombinedChartView
which haschartdata
&linedata
. The chartdata isgrouped
but the xAxis labels are not in center.I tried setting
xAxis.centerAxisLabelsEnabled = true
but the app crashed atIAxisValueFormatter
Below is the Formatter class :
The error I got :
fatal error: Index out of range
The value was somehow -1. I've no idea what went wrong. Without
centerAxisLabelsEnabled
, it works fine(though xAxis labels not centered).Below are my
datasets
:What could be the issue? Any help is much appreciated. @liuxuan30 @danielgindi
The text was updated successfully, but these errors were encountered: