在水平条形图中隐藏底部 x 轴?
Hide bottom x axis in horizontal bar chart?
我想使用不呈现任何 x 轴或网格线的 ios 图表呈现(堆叠)水平条形图。我已经禁用了我能找到的所有设置,但底部的 x 轴仍然呈现。
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
}
此代码生成以下渲染结果:
如何删除底轴渲染和垂直值线?
终于想通了。由于这是一个 HorizontalBarChart 轴的名称有点偏离。在该图的 bottom 上呈现的轴实际上是 rightAxis。因此这段代码可以解决问题:
barChart.rightAxis.enabled = false
启用 rightAxis 将导致 space 计算。如果你不想要它,请禁用它。然而,如果你确实想要它需要一些 space,但不绘制值、轴线、网格线、结帐 drawLabelsEnabled, drawGridLineEnabled, drawAxisLineEnabled
我想使用不呈现任何 x 轴或网格线的 ios 图表呈现(堆叠)水平条形图。我已经禁用了我能找到的所有设置,但底部的 x 轴仍然呈现。
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
}
此代码生成以下渲染结果:
如何删除底轴渲染和垂直值线?
终于想通了。由于这是一个 HorizontalBarChart 轴的名称有点偏离。在该图的 bottom 上呈现的轴实际上是 rightAxis。因此这段代码可以解决问题:
barChart.rightAxis.enabled = false
启用 rightAxis 将导致 space 计算。如果你不想要它,请禁用它。然而,如果你确实想要它需要一些 space,但不绘制值、轴线、网格线、结帐 drawLabelsEnabled, drawGridLineEnabled, drawAxisLineEnabled