I want the dates on the X-axis to follow without missing dates (i.e. 1, 2, 3, 4, and so on). When I know exactly how many columns there will be in the chart, I can solve the problem by calling setScaleMinima(_:scaleY:)
:
But when I have a large number of dates, with the same scale minima, the dates start to be grouped:
How can I make do that, regardless of the number of dates, all numbers without grouping are displayed on the X axis?
You can use setVisibleXRangeMinimum(minXRange:)
and setVisibleXRangeMaximum(maxXRange:)
to set the minimum and maximum number of chart columns. But these methods will only take effect if there is data in the chart (thx to this answer), so for convenience I call them every time the data changes:
public class MyChartView: BarChartView {
override public var data: ChartData? {
didSet {
self.setVisibleXRangeMinimum(2.0)
self.setVisibleXRangeMaximum(8.0)
}
}
}