forked from github/wulkanowy-mirror
Points statistics improvements (#2328)
This commit is contained in:
parent
516922d5aa
commit
5dffbdadfa
@ -22,6 +22,8 @@ import io.github.wulkanowy.databinding.ItemGradeStatisticsHeaderBinding
|
|||||||
import io.github.wulkanowy.databinding.ItemGradeStatisticsPieBinding
|
import io.github.wulkanowy.databinding.ItemGradeStatisticsPieBinding
|
||||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.max
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class GradeStatisticsAdapter @Inject constructor() :
|
class GradeStatisticsAdapter @Inject constructor() :
|
||||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
@ -269,7 +271,7 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
valueTextSize = 12f
|
valueTextSize = 12f
|
||||||
valueTextColor = binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
valueTextColor = binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
valueFormatter = object : ValueFormatter() {
|
valueFormatter = object : ValueFormatter() {
|
||||||
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}%"
|
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}"
|
||||||
}
|
}
|
||||||
colors = gradePointsColors
|
colors = gradePointsColors
|
||||||
}
|
}
|
||||||
@ -304,15 +306,20 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
xAxis.setDrawLabels(false)
|
xAxis.setDrawLabels(false)
|
||||||
xAxis.setDrawGridLines(false)
|
xAxis.setDrawGridLines(false)
|
||||||
|
|
||||||
|
val yMaxFromValues = (max(points.others, points.student)).roundToInt() + 30f
|
||||||
|
val yMaxFromValuesWithMargin = ((yMaxFromValues / 10.0).roundToInt() * 10).toFloat()
|
||||||
|
val yMax = yMaxFromValuesWithMargin.coerceAtLeast(100f)
|
||||||
|
val yLabelCount = (yMax / 10).toInt() + 1
|
||||||
with(axisLeft) {
|
with(axisLeft) {
|
||||||
axisMinimum = 0f
|
axisMinimum = 0f
|
||||||
axisMaximum = 100f
|
axisMaximum = yMax
|
||||||
labelCount = 11
|
labelCount = yLabelCount
|
||||||
}
|
}
|
||||||
with(axisRight) {
|
with(axisRight) {
|
||||||
axisMinimum = 0f
|
axisMinimum = 0f
|
||||||
axisMaximum = 100f
|
axisMaximum = yMax
|
||||||
labelCount = 11
|
labelCount = yLabelCount
|
||||||
}
|
}
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user