-
-
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
Full control over x labels in 3.0.0 #1804
Comments
in 3.0, x axis behaves like y axis, not indexed based axis anymore. So you have to clean up your mind and think in the new way. The x axis labels range are calculated by For you question, // force label count
if axis.isForceLabelsEnabled
{
interval = Double(range) / Double(labelCount - 1)
// Ensure stops contains at least n elements.
axis.entries.removeAll(keepingCapacity: true)
axis.entries.reserveCapacity(labelCount)
var v = yMin
for _ in 0 ..< labelCount
{
axis.entries.append(v)
v += interval
}
n = labelCount
} Is how labelCount works. You can override this part to have interval = 7. |
Thank you @liuxuan30. My final solution is:
Use the new renderer:
Set label interval:
|
I have been performing migration from 2.1.6 version of iOS charts library to 3.0.0.
And after APIs changed I am no longer able to set labels on exact positions on my chart.
Example: Month can have from 29 to 31 days. The task is to have labels for each 7 days: |1 |8 |15 |22 |29. The issue is that if I use
[xAxis setLabelCount:5 force:YES];
I will get different values depending on number of days in month in delegate method of IChartAxisValueFormatter protocol.
In 2.1.6 version of library the delegate method was called for each x and now only lablesCount amount of times with automatically computed values.
Is there any way to have full control over x labels in 3.0.0? Or I am doing something wrong?
The text was updated successfully, but these errors were encountered: