iOS图表会删除条形图栏上的值

时间:2019-02-14 09:37:19

标签: ios swift bar-chart ios-charts

我正在使用https://github.com/danielgindi/Charts enter image description here

如何隐藏每个栏中显示的值。 我的代码如下

func setUpChartView(){
    viewGraphContent.delegate = self
    viewGraphContent.pinchZoomEnabled = false
    viewGraphContent.chartDescription?.enabled = true
    viewGraphContent.dragEnabled = false
    viewGraphContent.setScaleEnabled(false)
    viewGraphContent.highlightFullBarEnabled = true
    viewGraphContent.doubleTapToZoomEnabled = false
    viewGraphContent.drawBordersEnabled = true
    viewGraphContent.borderColor = UIColor.white
    viewGraphContent.borderLineWidth = 1
    viewGraphContent.legend.enabled = false
  }

1 个答案:

答案 0 :(得分:3)

在设置图表集的位置添加以下代码行以解决问题:

var set = BarChartDataSet(values: yVals, label: "Data Set")        
set.drawValuesEnabled = false       // Set this property to false to hide all values

let data = BarChartData(dataSet: set)
yourChartView.data = data

此代码将隐藏条形图上方的所有值。希望对您有帮助。