Change HeartRate graph representation

This commit is contained in:
Milos Kozak 2023-08-24 23:05:12 +02:00
parent def6c51fa2
commit fd696a0c4b
5 changed files with 10 additions and 5 deletions

View file

@ -151,6 +151,6 @@ interface OverviewData {
var dsMaxSeries: LineGraphSeries<ScaledDataPoint> var dsMaxSeries: LineGraphSeries<ScaledDataPoint>
var dsMinSeries: LineGraphSeries<ScaledDataPoint> var dsMinSeries: LineGraphSeries<ScaledDataPoint>
var heartRateScale: Scale var heartRateScale: Scale
var heartRateGraphSeries: LineGraphSeries<DataPointWithLabelInterface> var heartRateGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface>
} }

View file

@ -17,7 +17,7 @@ class HeartRateDataPoint(
override val label: String = "" override val label: String = ""
override val duration = data.duration override val duration = data.duration
override val shape = PointsWithLabelGraphSeries.Shape.HEARTRATE override val shape = PointsWithLabelGraphSeries.Shape.HEARTRATE
override val size = 1f override val size = 10f
override val paintStyle: Paint.Style = Paint.Style.FILL override val paintStyle: Paint.Style = Paint.Style.FILL
override fun color(context: Context?): Int = rh.gac(context, info.nightscout.core.ui.R.attr.heartRateColor) override fun color(context: Context?): Int = rh.gac(context, info.nightscout.core.ui.R.attr.heartRateColor)

View file

@ -245,6 +245,11 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), endX, endY, mPaint); canvas.drawText(value.getLabel(), endX, endY, mPaint);
} }
} else if (value.getShape() == Shape.HEARTRATE) {
mPaint.setStrokeWidth(0);
Rect bounds = new Rect((int) endX, (int) endY - 8, (int) (xPlusLength), (int) endY + 8);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(bounds, mPaint);
} else if (value.getShape() == Shape.PROFILE) { } else if (value.getShape() == Shape.PROFILE) {
Drawable drawable = ContextCompat.getDrawable(graphView.getContext(), R.drawable.ic_ribbon_profile); Drawable drawable = ContextCompat.getDrawable(graphView.getContext(), R.drawable.ic_ribbon_profile);
assert drawable != null; assert drawable != null;

View file

@ -102,7 +102,7 @@ class OverviewDataImpl @Inject constructor(
epsSeries = PointsWithLabelGraphSeries() epsSeries = PointsWithLabelGraphSeries()
maxTherapyEventValue = 0.0 maxTherapyEventValue = 0.0
therapyEventSeries = PointsWithLabelGraphSeries() therapyEventSeries = PointsWithLabelGraphSeries()
heartRateGraphSeries = LineGraphSeries() heartRateGraphSeries = PointsWithLabelGraphSeries()
} }
override fun initRange() { override fun initRange() {
@ -339,5 +339,5 @@ class OverviewDataImpl @Inject constructor(
override var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var dsMaxSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
override var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries() override var dsMinSeries: LineGraphSeries<ScaledDataPoint> = LineGraphSeries()
override var heartRateScale = Scale() override var heartRateScale = Scale()
override var heartRateGraphSeries: LineGraphSeries<DataPointWithLabelInterface> = LineGraphSeries() override var heartRateGraphSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries()
} }

View file

@ -132,7 +132,7 @@ class PrepareTreatmentsDataWorker(
data.overviewData.therapyEventSeries = PointsWithLabelGraphSeries(filteredTherapyEvents.toTypedArray()) data.overviewData.therapyEventSeries = PointsWithLabelGraphSeries(filteredTherapyEvents.toTypedArray())
data.overviewData.epsSeries = PointsWithLabelGraphSeries(filteredEps.toTypedArray()) data.overviewData.epsSeries = PointsWithLabelGraphSeries(filteredEps.toTypedArray())
data.overviewData.heartRateGraphSeries = LineGraphSeries<DataPointWithLabelInterface>( data.overviewData.heartRateGraphSeries = PointsWithLabelGraphSeries<DataPointWithLabelInterface>(
repository.getHeartRatesFromTimeToTime(fromTime, endTime) repository.getHeartRatesFromTimeToTime(fromTime, endTime)
.map { hr -> HeartRateDataPoint(hr, rh) } .map { hr -> HeartRateDataPoint(hr, rh) }
.toTypedArray()).apply { color = rh.gac(null, info.nightscout.core.ui.R.attr.heartRateColor) } .toTypedArray()).apply { color = rh.gac(null, info.nightscout.core.ui.R.attr.heartRateColor) }