Charts: Horizontal Bar Chart rightAxis default maximum space

Created on 14 Apr 2017  路  6Comments  路  Source: danielgindi/Charts

Hi,

I'm trying to create a Horizontal Bar Chart where both ends (right and left axis) are aligned to the left and right side of the screen, with some offset. I've used the following code to remove both axises and set the axis minimum to zero.

self.leftAxis.enabled = false
self.leftAxis.axisMinimum = 0
self.rightAxis.enabled = false
self.rightAxis.axisMinimum = 0

The leftAxis is aligned the way is expecting it. However, the rightAxis is still showing some blank space. I can check this size with:

self.rightAxis.getRequiredHeightSpace()

Is there a way to remove or set this required space? I've tried to set spaceTop without success.

Here is an image as an example:

img_0010

Most helpful comment

After a few tests
In fact there is only the left side that walks
The right side has no effect

//: ### LeftAxis
let leftAxis = chartView.leftAxis
leftAxis.labelFont = NSUIFont.systemFont(ofSize: CGFloat(12.0))
leftAxis.drawAxisLineEnabled = true
leftAxis.drawGridLinesEnabled = true
leftAxis.axisMinimum = 0.0
leftAxis.enabled = true
leftAxis.spaceTop    = 0.0
leftAxis.spaceBottom = 0.0


//: ### RightAxis
let rightAxis                  = chartView.rightAxis
rightAxis.labelFont            = NSUIFont.systemFont(ofSize: CGFloat(12.0))
rightAxis.drawAxisLineEnabled  = true
rightAxis.drawGridLinesEnabled = false
rightAxis.axisMinimum          = 0.0
rightAxis.enabled              = true
rightAxis.spaceTop    = 0.5
rightAxis.spaceBottom = 0.5

All 6 comments

capture d ecran 2017-04-14 a 10 02 09

xAxis is Green
leftAxis is Blue
rightAxis is Red

Do you agree ??

Agree. I've updated the question above. When i enable the xAxis it will show the following:

img_0011

Maybe i wasn't clear before, but i want to remove the white space on the right side of the chart. I've added the current situation without the xAxis enabled in the Question above.

I know i can set a AxisMaximum to 100 and change the values of the bar so together they will always be 100. But is there a way to set the AxisMaximum to the total of the values, without displaying the white space?

ok i have understand

capture d ecran 2017-04-14 a 10 57 58

and now it's ok

capture d ecran 2017-04-14 a 11 07 58

Thanks, didn't know I had to set both the leftAxis and rightAxis Spaces

After a few tests
In fact there is only the left side that walks
The right side has no effect

//: ### LeftAxis
let leftAxis = chartView.leftAxis
leftAxis.labelFont = NSUIFont.systemFont(ofSize: CGFloat(12.0))
leftAxis.drawAxisLineEnabled = true
leftAxis.drawGridLinesEnabled = true
leftAxis.axisMinimum = 0.0
leftAxis.enabled = true
leftAxis.spaceTop    = 0.0
leftAxis.spaceBottom = 0.0


//: ### RightAxis
let rightAxis                  = chartView.rightAxis
rightAxis.labelFont            = NSUIFont.systemFont(ofSize: CGFloat(12.0))
rightAxis.drawAxisLineEnabled  = true
rightAxis.drawGridLinesEnabled = false
rightAxis.axisMinimum          = 0.0
rightAxis.enabled              = true
rightAxis.spaceTop    = 0.5
rightAxis.spaceBottom = 0.5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newbiebie picture newbiebie  路  3Comments

heumn picture heumn  路  3Comments

PrashantKT picture PrashantKT  路  3Comments

anhltse03448 picture anhltse03448  路  3Comments

valeIT picture valeIT  路  3Comments