Skip to content

Commit

Permalink
💄 Improve AllTime chart UI
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Colman Lopes <[email protected]>
  • Loading branch information
LeoColman committed Jan 16, 2025
1 parent cd50898 commit 51efed1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ fun AllTimeGraph(uses: List<Use>, dateFormat: String) {
labelCount = 5
granularity = 1f
valueFormatter = DaysSinceFirstUseFormatter(uses, dateFormat).formatDate
addLimitLine(LimitLine(YearMonth.now().monthValue.toFloat()).apply { lineWidth = 2f })

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fun LineChart(
chart.description.text = description
chart.description.textColor = colors.primary.toArgb()
chart.legend.textColor = colors.primary.toArgb()
chart.setMaxVisibleValueCount(30)

chart.data = LineData(datasets)
chart.notifyDataSetChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,27 @@ fun createAllTimeDistributionWithMovingAverage(uses: List<Use>): List<LineDataSe
fun createAllTimeLineDataSet(entryList: List<Entry>, label: String): LineDataSet {
return LineDataSet(entryList, label).apply {
valueFormatter = GramsValueFormatter
lineWidth = 6f
lineWidth = 3f
setDrawFilled(true)
setDrawCircles(false)
setDrawCircles(true)
setDrawCircleHole(true)
fillColor = Color.Cyan.copy(alpha = 0.3f).toArgb()
color = Color.Cyan.toArgb()
valueTextColor = Gray.toArgb()
valueTextSize = 14f
mode = LineDataSet.Mode.CUBIC_BEZIER
}
}

fun createAllTimeAverageDataSet(entryList: List<Entry>, label: String): LineDataSet {
return LineDataSet(entryList, label).apply {
setDrawValues(false)
setDrawCircles(false)
lineWidth = 6f
lineWidth = 3f
color = Color.Green.toArgb()
mode = LineDataSet.Mode.CUBIC_BEZIER
enableDashedLine(10f, 5f, 0f)

}
}

Expand All @@ -69,7 +74,7 @@ private fun calculateMovingAverage(entries: List<Entry>): List<Entry> {

val result = mutableListOf<Entry>()
for (i in entries.indices) {
val start = maxOf(0, i - 14 + 1)
val start = maxOf(0, i - 7 + 1)
val end = i + 1
val windowEntries = entries.subList(start, end)

Expand Down

0 comments on commit 51efed1

Please sign in to comment.