2016-03-24 13 views

risposta

12

C'è un metodo chiamato setDrawValues ​​che consente di abilitare o disabilitare il testo dell'etichetta. Qui un esempio a Swift con 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: Di sicuro nel tuo caso è possibile utilizzare questo metodo anche per l'oggetto BarChartData.

La documentazione può essere trovato qui (ios-classifiche si basa su MPAndroidChart e quindi ha, più o meno la stessa funzionalità): https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.2.3/javadoc/com/github/mikephil/charting/data/ChartData.html#setDrawValues(boolean)

+0

come attivare la setDrawValue per bar specifico come http: // stackoverflow.com/questions/41979926/how-to-achieve-trackball-on-charts-in-swift-3x ma questo è in swift 3 come posso ottenere la stessa cosa in swift 2 ?? –

5

È possibile disattivare le etichette aggiungendo la seguente riga;

lineData.setDrawValues(false) 
+0

Come aggiungere TrackBall e modificare l'etichetta sopra BarCharts nei grafici swift2 ?? http://stackoverflow.com/questions/41979926/how-to-achieve-trackball-on-charts-in-swift-3x –

-1

Impostare questo flag per

_chart.drawValueAboveBarEnabled = YES; 
+0

Questo non nasconde le etichette completamente ... le disegna sotto la parte superiore delle barre –

1

In swift3 seguente riga True o False può fare il lavoro:

chartDataSet.valueTextColor = UIColor.clear