Hide bottom x axis in horizontal bar chart?

Greg Ferreri

I want to render a (stacked) horizontal bar chart using ios-charts that does not render any x axis or grid lines. I've disabled every setting I can find, but the bottom x axis still renders.

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 results in the following rendering:

Still Renders x axis!!

How do I remove the bottom axis rendering and vertical value lines?

Greg Ferreri

Finally figured it out. Since this is a HorizontalBarChart the names of the axis are a little off. The axes that renders on the bottom of this graph is actually the rightAxis. Therefore this code does the trick:

barChart.rightAxis.enabled = false

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Rotate x axis text on Horizontal bar chart

Horizontal axis for bar chart

Fixing X-axis of Horizontal Plotly Bar Chart

to increase space between x axis and first horizontal bar in chart js

Custom D3 `tickValue` on x axis -- horizontal bar chart

How to hide the y axis and x axis line and label in my bar chart for chart.js

Multiple x axis on the bottom of chart

MP android chart displaying float values at X-Axis of Horizontal bar Chart?

Horizontal bar chart y axis alignment

JFreeChart - horizontal stacked bar chart with date axis

Echarts Bar Chart Axis Label on Top and Bottom

In chart.js, Is it possible to hide x-axis label/text of bar chart if accessing from mobile?

ZingCharts horizontal stacked bar chart X-Axis labels being cut off

How to add a line on x-axis on a horizontal bar chart in d3

Make bar chart's x-axis markers horizontal or 45 degree readable in Python Altair

How to animate a d3 js v4 bar chart from bottom(x axis) to up?

How to hide the Axis line in stack bar chart high chart

ggvis - Interactive X axis for bar chart

Reorder x axis in bar chart in ggplot

Bar chart labeled with % relative to the Months in X axis

How to move axis label to opposite side in Altair horizontal bar chart

Display y axis value horizontal line drawn In bar chart

Horizontal Stacked Bar Chart with Two Y Axis Issues

D3 Horizontal stacked bar chart axis cut off

Horizontal bar-chart: mis-matched axis units

Horizontal Bar Chart -- unexpected offsetting of y-axis

How can I create a horizontal bar chart in R that is split in the middle based off an additional variable on the x-axis?

How to hide/remove labels with No Data in a multiple labeled horizontal Bar Chart

Stacked bar chart swap x-axis and y-axis