How to remove a value label above each column in a histogram for ios charts

Each bar has a value above it, but whenever I get too many data records, these values ​​flow into each other and become unreadable. The only way I could edit them that I could find is to set them above or below each bar. However, I would like to hide them completely. How can I do this fast?

+7
source share
6 answers

There is a method called setDrawValues ​​that allows you to enable or disable label text. Here is an example in Swift with LineChart:

xValues = ["1","2"] yValues = [54.0, 42.0] var dataEntries: [ChartDataEntry] = [] for i in 0..<xValues.count { let dataEntry = ChartDataEntry(value: yvalues[i], xIndex: i) dataEntries.append(dataEntry) } let lineChartDataSet = LineChartDataSet(yVals: dataEntries, label: "YourData") let lineChartData = LineChartData(xVals: xValues, dataSet: lineChartDataSet) // this disables the display of the labels - be sure to apply it to your LineChartData object lineChartData.setDrawValues(false) 

Edit: In this case, you can also use this method for your BarChartData object.

The documentation can be found here (ios diagrams are based on MPAndroidChart and therefore have more or less the same functionality): https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.2.3/javadoc/com/github/mikephil/ charting / data / ChartData.html # setDrawValues ​​(boolean)

+13
source

You can disable shortcuts by adding the following line:

 lineData.setDrawValues(false) 
+7
source

You can use drawValuesEnabled as shown below:

 let chartDataSet = BarChartDataSet(yVals: dataEntries, label: nil) chartDataSet.drawValuesEnabled = false 
+3
source

In swift3, the following line can do the job:

 chartDataSet.valueTextColor = UIColor.clear 
+1
source

It does the trick for Swift 4

 yourChartDataSet.drawValuesEnabled = false 
0
source

Set this flag to True or False.

 _chart.drawValueAboveBarEnabled = YES; 
-one
source

All Articles