2

I'm learning ios-charts and I was wondering how to manipulare the yAxis since there is no method related to that. On the contrary xAxis can be customized. A small example, by default I have two set of labels for the yAxis as the figure shows.

My line plot

I managed to move the xAxis labels using

lineChartView.xAxis.labelPosition = .Bottom

but there is no such thing for the yAxis. Is it possible to leave just the labels on the left clearing the labels on the right?

Nicholas
  • 1,915
  • 31
  • 55

2 Answers2

7

use rightAxis.drawLabelsEnabled = false or even rightAxis.enabled = false.

The xAxis is rendered by xIndex, which means the distance between each data point on xAxis is equal. But yAxis is rendered by the data value and the yaxis range.

So be careful, when you are setting the dataSet, you got a chance to set the axis dependency, like dataSet.axisDependency = axisDependencyRight. Then it will use rightAxis to render your line chart, not left axis. By default, it is axisDependencyLeft

You can choose which yAxis you would like to have, and just disable the other one. rightAxis.drawLabelsEnabled = false just don't render the label, but still calculated and rendererd. Watch out for this.

Wingzero
  • 9,644
  • 10
  • 39
  • 80
4

I think that the only way to do it is the following

let yaxis = lineChartView.getAxis(ChartYAxis.AxisDependency.Right)
yaxis.drawLabelsEnabled = false

enter image description here

Nicholas
  • 1,915
  • 31
  • 55