Daviti Khvedelidze
Daviti Khvedelidze

Reputation: 29

DGCharts Y-axis labels are not aligned to left

I am using DGCharts and Y-axis labels aren't aligned to the left but are aligned to the right.

enter image description here

By default

chartView.leftAxis.labelAlignment = .left

I tried explicitly setting .left to labelAlignment but it still doesn't work.

Upvotes: 0

Views: 304

Answers (1)

sonle
sonle

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

Related Questions