Reputation: 29
I am using DGCharts and Y-axis labels aren't aligned to the left but are aligned to the right.
By default
chartView.leftAxis.labelAlignment = .left
I tried explicitly setting .left
to labelAlignment
but it still doesn't work.
Upvotes: 0
Views: 304
Reputation: 9191
In my experience, neither labelAlignment left nor right works with labelPosition == .outsideChart
. The chart always takes left with .insideChart
and right with .outsideChart
.
In case you just want a little spacing between leftAxis's label and the chart content, you can try this:
chartView.leftAxis.xOffset = 8
Or custom IndexAxisValueFormatter
with spacings.
class MyYAsixFormatter: IndexAxisValueFormatter {
override func stringForValue(_ value: Double, axis: AxisBase?) -> String {
return "\(value) "
}
}
...
chartView.leftAxis.valueFormatter = MyYAsixFormatter()
Upvotes: 2