forked from penguin86/luna-tracker
Compare commits
6 Commits
64fde74e2e
...
71c0bf6644
| Author | SHA1 | Date | |
|---|---|---|---|
| 71c0bf6644 | |||
| 905aeadabe | |||
| 2a307fd77c | |||
| 176774352c | |||
| 104bb08134 | |||
| 8684270a22 |
@@ -14,7 +14,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.graphics.toColorInt
|
import androidx.core.graphics.toColorInt
|
||||||
import com.github.mikephil.charting.animation.ChartAnimator
|
import com.github.mikephil.charting.animation.ChartAnimator
|
||||||
import com.github.mikephil.charting.charts.BarChart
|
import com.github.mikephil.charting.charts.BarChart
|
||||||
import com.github.mikephil.charting.components.YAxis
|
|
||||||
import com.github.mikephil.charting.data.BarData
|
import com.github.mikephil.charting.data.BarData
|
||||||
import com.github.mikephil.charting.data.BarDataSet
|
import com.github.mikephil.charting.data.BarDataSet
|
||||||
import com.github.mikephil.charting.data.BarEntry
|
import com.github.mikephil.charting.data.BarEntry
|
||||||
@@ -280,8 +279,8 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
//Log.d(TAG, "Range $index, vals: ${vals.joinToString { it.toInt().toString() }}") //, allColors: ${allColors.joinToString { it.toString() }}")
|
//Log.d(TAG, "Range $index, vals: ${vals.joinToString { it.toInt().toString() }}") //, allColors: ${allColors.joinToString { it.toString() }}")
|
||||||
|
|
||||||
assert(values.size == index)
|
//Log.d(TAG, "index: ${index.toFloat()}")
|
||||||
values.add(BarEntry(values.size.toFloat(), vals.toFloatArray()))
|
values.add(BarEntry(index.toFloat(), vals.toFloatArray()))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.d(TAG, "daysWithData: ${state.dayCounter.daysWithData.joinToString()}")
|
//Log.d(TAG, "daysWithData: ${state.dayCounter.daysWithData.joinToString()}")
|
||||||
@@ -351,27 +350,28 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
val set1 = BarDataSet(values, "")
|
val set1 = BarDataSet(values, "")
|
||||||
|
val data = BarData(set1)
|
||||||
set1.colors = allColors
|
set1.colors = allColors
|
||||||
|
|
||||||
set1.setDrawValues(false) // usually too many values
|
set1.setDrawValues(false) // usually too many values
|
||||||
set1.isHighlightEnabled = true
|
set1.isHighlightEnabled = true
|
||||||
|
|
||||||
set1.setDrawIcons(false)
|
set1.setDrawIcons(false)
|
||||||
|
|
||||||
//Log.d(TAG, "showSleepPatternBarGraphSlotted; barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}, barChart.visibleXRange: ${barChart.visibleXRange}, barChart.xAxis.isCenterAxisLabelsEnabled: ${barChart.xAxis.isCenterAxisLabelsEnabled}, barChart.isAutoScaleMinMaxEnabled: ${barChart.isAutoScaleMinMaxEnabled}, barChart.isScaleXEnabled: ${barChart.isScaleXEnabled}, barChart.isScaleYEnabled: ${barChart.isScaleYEnabled}")
|
//Log.d(TAG, "showSleepPatternBarGraphSlotted; barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}, barChart.visibleXRange: ${barChart.visibleXRange}, barChart.xAxis.isCenterAxisLabelsEnabled: ${barChart.xAxis.isCenterAxisLabelsEnabled}, barChart.isAutoScaleMinMaxEnabled: ${barChart.isAutoScaleMinMaxEnabled}, barChart.isScaleXEnabled: ${barChart.isScaleXEnabled}, barChart.isScaleYEnabled: ${barChart.isScaleYEnabled}")
|
||||||
|
|
||||||
val data = BarData(set1)
|
|
||||||
data.setValueTextSize(12f)
|
data.setValueTextSize(12f)
|
||||||
|
barChart.setData(data)
|
||||||
|
|
||||||
// does not work quite right yet
|
// does not work quite right yet
|
||||||
//Log.d(TAG, "xChartMax: ${barChart.xChartMax}")
|
//Log.d(TAG, "xChartMax: ${barChart.xChartMax}")
|
||||||
//barChart.centerViewTo(barChart.xChartMax, 0F, YAxis.AxisDependency.LEFT)
|
//barChart.centerViewTo(barChart.xChartMax, 0F, YAxis.AxisDependency.LEFT)
|
||||||
|
|
||||||
val valueCount = min(values.size, 24)
|
|
||||||
barChart.setData(data)
|
|
||||||
barChart.legend.isEnabled = false
|
barChart.legend.isEnabled = false
|
||||||
|
val valueCount = min(values.size, 24)
|
||||||
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
||||||
barChart.xAxis.setLabelCount(valueCount)
|
barChart.xAxis.setLabelCount(valueCount)
|
||||||
barChart.xAxis.setCenterAxisLabels(false)
|
barChart.xAxis.setCenterAxisLabels(false)
|
||||||
barChart.moveViewTo(data.getEntryCount().toFloat(), 0f, YAxis.AxisDependency.LEFT)
|
|
||||||
barChart.invalidate()
|
barChart.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,8 +402,7 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// update value
|
// update value
|
||||||
val newYVals = appendToFloatArray(yVals, awakeDuration.toFloat(), sleepDuration.toFloat())
|
val newYVals = appendToFloatArray(yVals, awakeDuration.toFloat(), sleepDuration.toFloat())
|
||||||
assert(index == x.toInt())
|
values[index] = BarEntry(x, newYVals)
|
||||||
values[index] = BarEntry(index.toFloat(), newYVals)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (range in ranges) {
|
for (range in ranges) {
|
||||||
@@ -434,11 +433,12 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// awake phase color is transparent
|
|
||||||
val set1 = BarDataSet(values, "")
|
val set1 = BarDataSet(values, "")
|
||||||
|
val data = BarData(set1)
|
||||||
|
|
||||||
|
// awake phase color is transparent
|
||||||
set1.colors = arrayListOf("#00000000".toColorInt(), "#72d7f5".toColorInt())
|
set1.colors = arrayListOf("#00000000".toColorInt(), "#72d7f5".toColorInt())
|
||||||
set1.setDrawValues(false) // usually too many values
|
set1.setDrawValues(false) // usually too many values
|
||||||
set1.setDrawIcons(false)
|
|
||||||
set1.isHighlightEnabled = true
|
set1.isHighlightEnabled = true
|
||||||
|
|
||||||
barChart.setOnChartValueSelectedListener(object : OnChartValueSelectedListener {
|
barChart.setOnChartValueSelectedListener(object : OnChartValueSelectedListener {
|
||||||
@@ -479,19 +479,18 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
override fun onNothingSelected() {}
|
override fun onNothingSelected() {}
|
||||||
})
|
})
|
||||||
//Log.d(TAG, "showSleepPatternBarGraphDaily: values.size: ${values.size}, barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}")
|
//Log.d(TAG, "showSleepPatternBarGraphDaily: values.size: ${values.size}, barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}")
|
||||||
|
set1.setDrawIcons(false)
|
||||||
|
|
||||||
val data = BarData(set1)
|
|
||||||
data.setValueTextSize(12f)
|
data.setValueTextSize(12f)
|
||||||
|
barChart.setData(data)
|
||||||
|
|
||||||
//Log.d(TAG, "showSleepPatternBarGraphDaily: new barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}")
|
//Log.d(TAG, "showSleepPatternBarGraphDaily: new barChart.xAxis.labelCount: ${barChart.xAxis.labelCount}")
|
||||||
|
|
||||||
val valueCount = min(values.size, 24)
|
|
||||||
barChart.setData(data)
|
|
||||||
barChart.legend.isEnabled = false
|
barChart.legend.isEnabled = false
|
||||||
|
val valueCount = min(values.size, 24)
|
||||||
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
||||||
barChart.xAxis.setLabelCount(valueCount)
|
barChart.xAxis.setLabelCount(valueCount)
|
||||||
barChart.xAxis.setCenterAxisLabels(false)
|
barChart.xAxis.setCenterAxisLabels(false)
|
||||||
barChart.moveViewTo(data.getEntryCount().toFloat(), 0f, YAxis.AxisDependency.LEFT)
|
|
||||||
barChart.invalidate()
|
barChart.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,7 +592,6 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
||||||
barChart.xAxis.setLabelCount(valueCount)
|
barChart.xAxis.setLabelCount(valueCount)
|
||||||
barChart.xAxis.setCenterAxisLabels(false)
|
barChart.xAxis.setCenterAxisLabels(false)
|
||||||
barChart.moveViewTo(data.getEntryCount().toFloat(), 0f, YAxis.AxisDependency.LEFT)
|
|
||||||
barChart.invalidate()
|
barChart.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +654,6 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
barChart.setVisibleXRangeMaximum(valueCount.toFloat())
|
||||||
barChart.xAxis.setLabelCount(valueCount)
|
barChart.xAxis.setLabelCount(valueCount)
|
||||||
barChart.xAxis.setCenterAxisLabels(false)
|
barChart.xAxis.setCenterAxisLabels(false)
|
||||||
barChart.moveViewTo(data.getEntryCount().toFloat(), 0f, YAxis.AxisDependency.LEFT)
|
|
||||||
barChart.invalidate()
|
barChart.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user