Mise à jour des légendes des graphiques

This commit is contained in:
arussac
2025-03-13 09:40:08 +01:00
parent f1655d2713
commit 5d908dca42

View File

@@ -177,6 +177,34 @@ class ProjectActivity : AppCompatActivity() {
xAxis.labelRotationAngle = -90f xAxis.labelRotationAngle = -90f
xAxis.position = XAxis.XAxisPosition.BOTTOM xAxis.position = XAxis.XAxisPosition.BOTTOM
// Configure the left y-axis
val leftYAxis = temperatureHumidityChart.axisLeft
leftYAxis.labelCount = 6 // Set the number of labels
leftYAxis.setLabelCount(6, true)
leftYAxis.setDrawLabels(true)
leftYAxis.setDrawAxisLine(true)
leftYAxis.setDrawGridLines(true)
leftYAxis.valueFormatter = object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
return "${value.toInt()}" // Append "C°" to the temperature values
}
}
// Configure the right y-axis
val rightYAxis = temperatureHumidityChart.axisRight
rightYAxis.labelCount = 6 // Set the number of labels
rightYAxis.axisMinimum = 0f // Set minimum value if needed
rightYAxis.axisMaximum = 100f // Set maximum value to 100%
rightYAxis.setLabelCount(6, true)
rightYAxis.setDrawLabels(true)
rightYAxis.setDrawAxisLine(true)
rightYAxis.setDrawGridLines(false)
rightYAxis.valueFormatter = object : ValueFormatter() {
override fun getFormattedValue(value: Float): String {
return "${value.toInt()} %" // Append "%" to the humidity values
}
}
// Add datasets to the chart // Add datasets to the chart
val dataSets: MutableList<ILineDataSet> = ArrayList() val dataSets: MutableList<ILineDataSet> = ArrayList()
dataSets.add(temperatureDataSet) dataSets.add(temperatureDataSet)