-
-
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
Values on X axis issue #3304
Comments
check |
@liuxuan30 - does the demo project have an example that overrides |
no, it's default one. The logic is simple, just do math or none |
So when we need to manually override the computeAxisValues() for the XAxisRenderer. Here is an example @JCMcLovin : class NonUniformXAxisRenderer: XAxisRenderer {
override func computeAxisValues(min: Double, max: Double) {
super.computeAxisValues(min: min, max: max)
guard let axis = self.axis else { return }
let labelCount = axis.labelCount
let interval = 86400000.0
// Ensure stops contains at least n elements.
axis.entries.removeAll(keepingCapacity: true)
axis.entries.reserveCapacity(labelCount)
axis.entries.append(min)
var v = min + 26423301
for _ in 0 ..< labelCount - 2
{
axis.entries.append(v)
v += interval
}
axis.entries.append(max)
}
} let transformer = chartView.getTransformer(forAxis:.left)
let viewPortHandler = chartView.xAxisRenderer.viewPortHandler
chartView.xAxisRenderer = NonUniformXAxisRenderer(viewPortHandler: viewPortHandler, xAxis: chartView.xAxis, transformer: transformer) Take note you cannot use your own transformer and viewPortHandler instance. ChartXAxis Value Not Displayed @liuxuan30 the logic is simple but it did take me hours to figure out why the axis label not showing. I used my own transformer and viewPortHandler instance and read all the related source code to know why it does not work. |
I use ScatterChart. On the x axis labels should be hours (00:00, 06:00, 12:00, 18:00). But, If I put minimum = 0 and maximum = 1440 (minutes in day) and and label count to 5 I get graph like this:
If I set labelCount to 4, labels on xAxis are: 00:00, 06:40 (400), 13:20 (800), 20:00 (1200).
If labelCount = 3 axis are 00:00, 08:20 (500), 16:40 (1000)
This is my setup:
vwChart.xAxis.axisMinimum = 0 vwChart.xAxis.axisMaximum = 1440 vwChart.setVisibleXRangeMaximum(1440) vwChart.setVisibleXRangeMinimum(1440) vwChart.xAxis.labelCount = 4 // 5, 6, 3, 2
Is there a way to specify interval between labels, so I can display each 6h?
The text was updated successfully, but these errors were encountered: