Hide bottom x axis in horizontal bar graph?

I want to visualize a horizontal histogram (stacked) using ios diagrams that does not display either the x axis or the grid line. I turned off all the settings that I can find, but the bottom x axis is still displayed.

func setUpBarChart() { // General bar chart settings barChart.pinchZoomEnabled = false barChart.drawGridBackgroundEnabled = false barChart.drawBarShadowEnabled = false barChart.drawValueAboveBarEnabled = false barChart.drawBordersEnabled = false barChart.drawMarkers = false barChart.legend.enabled = false barChart.descriptionText = "" barChart.drawBordersEnabled = false // Left-axis settings barChart.leftAxis.drawLabelsEnabled = false barChart.leftAxis.drawTopYLabelEntryEnabled = false barChart.leftAxis.drawAxisLineEnabled = false // x-axis settings barChart.xAxis.drawAxisLineEnabled = false barChart.xAxis.drawGridLinesEnabled = false barChart.xAxis.drawLabelsEnabled = false barChart.xAxis.enabled = false // add some dummy data let entry = BarChartDataEntry(values: [10,2,5], xIndex: 0) let set = BarChartDataSet(yVals: [entry], label: nil) set.colors = [UIColor.greenColor(), UIColor.yellowColor(), UIColor.redColor()] set.drawValuesEnabled = false let data = BarChartData(xVals: [""], dataSet: set) barChart.data = data } 

this code leads to the following rendering:

Shows the x axis!

How to remove bottom axis output lines and vertical values?

+5
source share
2 answers

Finally figured it out. Since this is a HorizontalBarChart, the axis names are a bit inactive. The axes that appear at the bottom of this graph are actually rightAxis . Therefore, this code does the trick:

 barChart.rightAxis.enabled = false 
+6
source

enabling Axis will calculate the space. Disable if you do not want this. However, if you want this to take up some space but just not draw values, axis lines, grid lines, checkout drawLabelsEnabled, drawGridLineEnabled, drawAxisLineEnabled

+1
source

Source: https://habr.com/ru/post/1239446/


All Articles