1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-09-01 03:55:47 +02:00

Steps/Sleep activties: update lines and offsets

This commit is contained in:
a0z 2024-08-27 23:26:21 +02:00 committed by José Rebelo
parent 39707a52da
commit 88c8629ec0
3 changed files with 16 additions and 14 deletions

View File

@ -147,7 +147,12 @@ public abstract class AbstractWeekChartFragment extends AbstractActivityChartFra
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false); barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);
barData.setValueTextSize(10f); barData.setValueTextSize(10f);
barChart.getAxisLeft().setAxisMaximum(Math.max(set.getYMax(), mTargetValue) + 60);
LimitLine target = new LimitLine(mTargetValue); LimitLine target = new LimitLine(mTargetValue);
target.setLineWidth(1.5f);
target.enableDashedLine(15f, 10f, 0f);
target.setLineColor(getResources().getColor(R.color.chart_deep_sleep_dark));
barChart.getAxisLeft().removeAllLimitLines(); barChart.getAxisLeft().removeAllLimitLines();
barChart.getAxisLeft().addLimitLine(target); barChart.getAxisLeft().addLimitLine(target);
@ -156,6 +161,8 @@ public abstract class AbstractWeekChartFragment extends AbstractActivityChartFra
average = Math.abs(balance / TOTAL_DAYS_FOR_AVERAGE); average = Math.abs(balance / TOTAL_DAYS_FOR_AVERAGE);
} }
LimitLine average_line = new LimitLine(average); LimitLine average_line = new LimitLine(average);
average_line.setLineWidth(1.5f);
average_line.enableDashedLine(15f, 10f, 0f);
average_line.setLabel(getString(R.string.average, getAverage(average))); average_line.setLabel(getString(R.string.average, getAverage(average)));
if (average > (mTargetValue)) { if (average > (mTargetValue)) {

View File

@ -25,7 +25,6 @@ import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet; import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -34,10 +33,7 @@ import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
@ -144,10 +140,6 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
stepsEntry.label = getString(R.string.steps); stepsEntry.label = getString(R.string.steps);
stepsEntry.formColor = getResources().getColor(R.color.steps_color); stepsEntry.formColor = getResources().getColor(R.color.steps_color);
legendEntries.add(stepsEntry); legendEntries.add(stepsEntry);
final LegendEntry goalEntry = new LegendEntry();
goalEntry.label = getString(R.string.miband_prefs_fitness_goal);
goalEntry.formColor = Color.GRAY;
legendEntries.add(goalEntry);
stepsChart.getLegend().setTextColor(TEXT_COLOR); stepsChart.getLegend().setTextColor(TEXT_COLOR);
stepsChart.getLegend().setCustom(legendEntries); stepsChart.getLegend().setCustom(legendEntries);
@ -184,11 +176,12 @@ public class StepsDailyFragment extends StepsFragment<StepsDailyFragment.StepsDa
lineDataSet.setFillColor(getResources().getColor(R.color.steps_color )); lineDataSet.setFillColor(getResources().getColor(R.color.steps_color ));
final LimitLine goalLine = new LimitLine(STEPS_GOAL); final LimitLine goalLine = new LimitLine(STEPS_GOAL);
goalLine.setLineColor(Color.GRAY); goalLine.setLineColor(getResources().getColor(R.color.steps_color));
goalLine.setLineWidth(1.5f); goalLine.setLineWidth(1.5f);
goalLine.enableDashedLine(10f, 10f, 0f); goalLine.enableDashedLine(15f, 10f, 0f);
stepsChart.getAxisLeft().removeAllLimitLines(); stepsChart.getAxisLeft().removeAllLimitLines();
stepsChart.getAxisLeft().addLimitLine(goalLine); stepsChart.getAxisLeft().addLimitLine(goalLine);
stepsChart.getAxisLeft().setAxisMaximum(Math.max(lineDataSet.getYMax(), STEPS_GOAL) + 2000);
final List<ILineDataSet> lineDataSets = new ArrayList<>(); final List<ILineDataSet> lineDataSets = new ArrayList<>();
lineDataSets.add(lineDataSet); lineDataSets.add(lineDataSet);

View File

@ -112,10 +112,11 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
yAxisLeft.setEnabled(true); yAxisLeft.setEnabled(true);
yAxisLeft.setTextColor(CHART_TEXT_COLOR); yAxisLeft.setTextColor(CHART_TEXT_COLOR);
yAxisLeft.setAxisMinimum(0f); yAxisLeft.setAxisMinimum(0f);
final LimitLine target = new LimitLine(STEPS_GOAL); final LimitLine goalLine = new LimitLine(STEPS_GOAL);
target.setLineColor(Color.GRAY); goalLine.setLineColor(getResources().getColor(R.color.steps_color));
target.enableDashedLine(10f, 10f, 0f); goalLine.setLineWidth(1.5f);
yAxisLeft.addLimitLine(target); goalLine.enableDashedLine(15f, 10f, 0f);
yAxisLeft.addLimitLine(goalLine);
final YAxis yAxisRight = stepsChart.getAxisRight(); final YAxis yAxisRight = stepsChart.getAxisRight();
yAxisRight.setEnabled(true); yAxisRight.setEnabled(true);
@ -166,6 +167,7 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
set.setColors(getResources().getColor(R.color.steps_color)); set.setColors(getResources().getColor(R.color.steps_color));
final XAxis x = stepsChart.getXAxis(); final XAxis x = stepsChart.getXAxis();
x.setValueFormatter(getStepsChartDayValueFormatter(stepsData)); x.setValueFormatter(getStepsChartDayValueFormatter(stepsData));
stepsChart.getAxisLeft().setAxisMaximum(Math.max(set.getYMax(), STEPS_GOAL) + 2000);
BarData barData = new BarData(set); BarData barData = new BarData(set);
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false); barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);