forked from penguin86/luna-tracker
Compare commits
6 Commits
71c0bf6644
...
64fde74e2e
| Author | SHA1 | Date | |
|---|---|---|---|
| 64fde74e2e | |||
| d2a71d500d | |||
| 3d893fa7db | |||
| d64f0b9627 | |||
| 2dbfdcf9d5 | |||
| 0c8b7503f0 |
@@ -14,6 +14,7 @@ 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
|
||||||
@@ -279,8 +280,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() }}")
|
||||||
|
|
||||||
//Log.d(TAG, "index: ${index.toFloat()}")
|
assert(values.size == index)
|
||||||
values.add(BarEntry(index.toFloat(), vals.toFloatArray()))
|
values.add(BarEntry(values.size.toFloat(), vals.toFloatArray()))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.d(TAG, "daysWithData: ${state.dayCounter.daysWithData.joinToString()}")
|
//Log.d(TAG, "daysWithData: ${state.dayCounter.daysWithData.joinToString()}")
|
||||||
@@ -350,28 +351,27 @@ 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)
|
||||||
|
|
||||||
barChart.legend.isEnabled = false
|
|
||||||
val valueCount = min(values.size, 24)
|
val valueCount = min(values.size, 24)
|
||||||
|
barChart.setData(data)
|
||||||
|
barChart.legend.isEnabled = false
|
||||||
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,7 +402,8 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// update value
|
// update value
|
||||||
val newYVals = appendToFloatArray(yVals, awakeDuration.toFloat(), sleepDuration.toFloat())
|
val newYVals = appendToFloatArray(yVals, awakeDuration.toFloat(), sleepDuration.toFloat())
|
||||||
values[index] = BarEntry(x, newYVals)
|
assert(index == x.toInt())
|
||||||
|
values[index] = BarEntry(index.toFloat(), newYVals)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (range in ranges) {
|
for (range in ranges) {
|
||||||
@@ -433,12 +434,11 @@ class StatisticsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val set1 = BarDataSet(values, "")
|
|
||||||
val data = BarData(set1)
|
|
||||||
|
|
||||||
// awake phase color is transparent
|
// awake phase color is transparent
|
||||||
|
val set1 = BarDataSet(values, "")
|
||||||
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,18 +479,19 @@ 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}")
|
||||||
|
|
||||||
barChart.legend.isEnabled = false
|
|
||||||
val valueCount = min(values.size, 24)
|
val valueCount = min(values.size, 24)
|
||||||
|
barChart.setData(data)
|
||||||
|
barChart.legend.isEnabled = false
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,6 +593,7 @@ 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()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,6 +656,7 @@ 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