forked from penguin86/luna-tracker
Compare commits
6 Commits
016dbf330b
...
1763a9cfd0
| Author | SHA1 | Date | |
|---|---|---|---|
| 1763a9cfd0 | |||
| 3779e7e34d | |||
| 9a1f489b8b | |||
| dd02bbce65 | |||
| e6ac11d335 | |||
| e1e8832f51 |
@@ -297,6 +297,7 @@ class StatisticsActivity : AppCompatActivity() {
|
||||
|
||||
val dayStartUnix = daysToUnix(unixToDays(state.startUnix) + index)
|
||||
|
||||
//Log.d(TAG, "startUnix: ${Date(startUnix * 1000)}, x: ${e.x.toInt()}, dayStartUnix: ${Date(dayStartUnix * 1000)}")
|
||||
val startSeconds =
|
||||
SLEEP_PATTERN_GRANULARITY * value.yVals.sliceArray(0..<h.stackIndex)
|
||||
.fold(0) { acc, y -> acc + y.toInt() }
|
||||
@@ -487,6 +488,7 @@ class StatisticsActivity : AppCompatActivity() {
|
||||
fun showSleepBarGraph(state: GraphState) {
|
||||
val ranges = toSleepRanges(state.events)
|
||||
val values = ArrayList(List(state.endSpan - state.startSpan + 1) { BarEntry(it.toFloat(), 0F) })
|
||||
//Log.d(TAG, "startUnix: ${Date(state.startUnix * 1000)}, endUnix: ${Date(state.endUnix * 1000)}")
|
||||
|
||||
for (range in ranges) {
|
||||
// a sleep event can span to another day
|
||||
@@ -603,6 +605,7 @@ class StatisticsActivity : AppCompatActivity() {
|
||||
data.setValueFormatter(object : ValueFormatter() {
|
||||
override fun getFormattedValue(value: Float): String {
|
||||
val prefix = if (timeRangeSelection == TimeRange.DAY) { "" } else { "⌀ " }
|
||||
//Log.d(TAG, "getFormattedValue ${dataTypeSelectionValue} ${eventTypeSelectionValue}")
|
||||
return when (graphTypeSelection) {
|
||||
GraphType.BOTTLE_EVENTS -> {
|
||||
prefix + value.toInt().toString()
|
||||
@@ -638,6 +641,7 @@ class StatisticsActivity : AppCompatActivity() {
|
||||
val endDays = unixToDays(endUnix)
|
||||
var count = 0
|
||||
for (i in (beginDays - startDays)..<(endDays - startDays)) {
|
||||
//Log.d(TAG, "countDaysWithData: i: $i, size: ${daysWithData.size}")
|
||||
count += if (daysWithData[i]) { 1 } else { 0 }
|
||||
}
|
||||
return count
|
||||
@@ -657,6 +661,7 @@ class StatisticsActivity : AppCompatActivity() {
|
||||
data class GraphState(val events: List<LunaEvent>, val dayCounter: DayCounter, val startUnix: Long, val endUnix: Long, val startSpan: Int, val endSpan: Int)
|
||||
|
||||
fun showGraph() {
|
||||
//Log.d(TAG, "showGraph: graphTypeSelection: $graphTypeSelection, timeRangeSelection: $timeRangeSelection")
|
||||
barChart.fitScreen()
|
||||
barChart.data?.clearValues()
|
||||
barChart.xAxis.valueFormatter = null
|
||||
|
||||
Reference in New Issue
Block a user