Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple xAxis granularity setting in iOS Charts framework

Tags:

ios

swift

charts

i have been experimenting with the charts framework and things seems to be running as expected except the behavior of the xAxis.granularity setting.

barChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: ["A","B","C","D","E","F","G","H","I","J","K","L"])
barChartView.xAxis.granularityEnabled = true
barChartView.xAxis.granularity = 1

when i set granularity to 2 or above, i get the expected behavior of xAxis label spread out by the value i specified. (the 3 images are for a granularity of 2,3,4)

granularity = 2

granularity = 3

granularity = 4

but when i set granularity = 1 expecting a label under every barchart, i get this

granularity = 1

what am i missing ? or is there another setting to force a label at every point ? thanks

like image 458
Sami Avatar asked Mar 01 '26 06:03

Sami


1 Answers

Try setting

setLabelCount(12, force: true) // replace 12 with your data.count
like image 51
Lal Krishna Avatar answered Mar 02 '26 18:03

Lal Krishna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!