当我将minOffset设置为0时,它不会删除条形图中的额外填充/边距。
有没有办法隐藏那个空间? 附上截图,我想从顶部删除额外的空格/填充/边距。
如果你向其中一个条添加零,则此边距将增加。附上截图
Margin/space increase if one of the bars value is zero
图表的配置参数
func setUpGraph() {
self.vwChart.chartDescription?.enabled = false
self.vwChart.drawGridBackgroundEnabled = false
self.vwChart.drawBordersEnabled = false
self.vwChart.dragEnabled = false;
self.vwChart.setScaleEnabled(true)
self.vwChart.pinchZoomEnabled = false
self.vwChart.minOffset = 0
self.vwChart.animate(yAxisDuration: 1.0)
self.vwChart.xAxis.enabled = false
self.vwChart.leftAxis.enabled = false
self.vwChart.leftAxis.inverted = true
self.vwChart.rightAxis.enabled = false
self.vwChart.legend.enabled = false
self.vwChart.xAxis.drawAxisLineEnabled = false
self.vwChart.leftAxis.drawAxisLineEnabled = false
self.vwChart.rightAxis.drawAxisLineEnabled = false
self.vwChart.xAxis.drawGridLinesEnabled = false
self.vwChart.leftAxis.drawGridLinesEnabled = false
self.vwChart.rightAxis.drawGridLinesEnabled = false
self.vwChart.xAxis.drawLabelsEnabled = false
self.vwChart.xAxis.drawLabelsEnabled = false
self.vwChart.leftAxis.drawLabelsEnabled = false
self.vwChart.rightAxis.drawLabelsEnabled = false
}
func setGraphData() {
var yVals:Array<BarChartDataEntry> = Array<BarChartDataEntry>()
yVals.append(BarChartDataEntry(x: 0, y: 10))
yVals.append(BarChartDataEntry(x: 1, y: 5))
yVals.append(BarChartDataEntry(x: 2, y: 30))
yVals.append(BarChartDataEntry(x: 3, y: 10))
yVals.append(BarChartDataEntry(x: 4, y: 50))
yVals.append(BarChartDataEntry(x: 5, y: 15))
yVals.append(BarChartDataEntry(x: 6, y: 70))
yVals.append(BarChartDataEntry(x: 7, y: 20))
yVals.append(BarChartDataEntry(x: 8, y: 90))
yVals.append(BarChartDataEntry(x: 9, y: 25))
yVals.append(BarChartDataEntry(x: 10, y: 110))
yVals.append(BarChartDataEntry(x: 11, y: 30))
yVals.append(BarChartDataEntry(x: 12, y: 130))
yVals.append(BarChartDataEntry(x: 13, y: 35))
yVals.append(BarChartDataEntry(x: 14, y: 150))
yVals.append(BarChartDataEntry(x: 15, y: 40))
yVals.append(BarChartDataEntry(x: 16, y: 170))
yVals.append(BarChartDataEntry(x: 17, y: 50))
yVals.append(BarChartDataEntry(x: 18, y: 190))
let barChartDataSet = BarChartDataSet(values: yVals, label: "")
barChartDataSet.colors = [UIColor.violetBlue]
let barChartData = BarChartData(dataSet: barChartDataSet)
barChartData.barWidth = 0.4
barChartData.setDrawValues(false)
self.vwChart.data = barChartData
}
答案 0 :(得分:0)
请尝试添加以下行以排列栏:
self.vwChart.leftAxis.axisMinimum = 0.0
答案 1 :(得分:0)
您可以使用spaceBottom / spaceTop属性删除空格。
self.vwChart.leftAxis.spaceBottom = 0.0
self.vwChart.rightAxis.spaceBottom = 0.0
感谢。 希望这会有所帮助。