1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-25 22:40:05 +02:00

Add Averages to Charts

This commit is contained in:
vanous 2019-08-11 00:57:07 +02:00 committed by Andreas Shimokawa
parent c243541c6e
commit f11628b42b
2 changed files with 22 additions and 1 deletions

View File

@ -130,7 +130,27 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
barChart.getAxisLeft().removeAllLimitLines();
barChart.getAxisLeft().addLimitLine(target);
return new WeekChartsData(barData, new PreformattedXIndexLabelFormatter(labels), getBalanceMessage(balance, mTargetValue));
float average = 0;
if (TOTAL_DAYS > 0) {
average = Math.abs(balance / TOTAL_DAYS);
}
LimitLine average_line = new LimitLine(average);
average_line.setLabel(getString(R.string.average, average));
if (average > (mTargetValue)) {
average_line.setLineColor(Color.GREEN);
average_line.setTextColor(Color.GREEN);
}
else {
average_line.setLineColor(Color.RED);
average_line.setTextColor(Color.RED);
}
if (average > 0) {
barChart.getAxisLeft().addLimitLine(average_line);
}
return new WeekChartsData(barData, new PreformattedXIndexLabelFormatter(labels), getBalanceMessage(balance, mTargetValue));
}
private DayData refreshDayPie(DBHandler db, Calendar day, GBDevice device) {

View File

@ -417,6 +417,7 @@
<string name="weeksteps_today_steps_description">Steps today, target: %1$s</string>
<string name="lack_of_step">Lack of steps: %1$d</string>
<string name="overstep">Overstep: %1$d</string>
<string name="average">Average: %1$.0f</string>
<string name="pref_title_dont_ack_transfer">Do not ACK activity data transfer</string>
<string name="pref_summary_dont_ack_transfers">If the activity data are not acked to the band, they will not be cleared. Useful if GB is used together with other apps.</string>
<string name="pref_summary_keep_data_on_device">Will keep activity data on the Mi Band even after synchronization. Useful if GB is used together with other apps.</string>