0
Ich habe eine Liste mit Datum, auf dem Bild hat 3 Daten, aber die Grafik zeigt nur 2 Daten und zeigen an der falschen Stelle ... Wie alle Termine angezeigt werden, und wie zu machen das X zentriert auf der richtigen Position? (Nach y-Wert)Falsche X-Position auf mpandroidchart
for(treino in treinoList) {
entries.add(Entry(treino.data.toFloat(), treino.treinoTipo.toFloat()))
}
val desc = Description()
desc.text = ""
val dataSet = LineDataSet(entries, "Tempo/Treinos")
val lineData = LineData(dataSet)
chart.setNoDataText("Nenhum treino computado")
chart.setDrawBorders(false)
chart.data = lineData
chart.description = desc
chart.setGridBackgroundColor(R.color.graphGride)
chart.setDrawGridBackground(false)
chart.legend.textColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.axisLeft.gridColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.xAxis.position = XAxis.XAxisPosition.BOTTOM
chart.xAxis.textColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.xAxis.axisLineColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.xAxis.setCenterAxisLabels(true)
chart.xAxis.labelCount = treinoList.size
chart.xAxis.valueFormatter = object : IAxisValueFormatter{
val dateFormat = SimpleDateFormat("dd/MM", Locale.getDefault())
override fun getFormattedValue(value: Float, axis: AxisBase?): String {
return dateFormat.format(value)
}
}
chart.axisLeft.textColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.axisLeft.labelCount = 4
chart.axisLeft.axisLineColor = ActivityCompat.getColor(this, R.color.graphLabel)
chart.axisRight.setDrawLabels(false)
chart.animateX(500)
chart.invalidate()
Diese funktionieren nicht, begrenzen nur die Anzeige von Datum bis 5 –