diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/StatsChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/StatsChartFragment.java index 181508d9..18941054 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/StatsChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/StatsChartFragment.java @@ -43,8 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; - -import static android.R.attr.x; +import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; public class StatsChartFragment extends AbstractChartFragment { @@ -67,13 +66,17 @@ public class StatsChartFragment extends AbstractChartFragment { BarData data = new BarData(); data.setValueTextColor(CHART_TEXT_COLOR); List entries = new ArrayList<>(); - XAxisValueFormatter customXAxis = new XAxisValueFormatter(); - for (Map.Entry entry : analysis.statsQuantified.entrySet()) { - entries.add(new BarEntry(entry.getKey(), entry.getValue())); - /*float realValue = entry.getKey() * analysis.maxSpeedQuantifier; - String customLabel = Math.round(realValue * (1 - analysis.roundPrecision) * 10f) / 10f + " - " + Math.round(realValue * (1 + analysis.roundPrecision) * 10f) / 10f;*/ - customXAxis.add("" + entry.getKey() * analysis.maxSpeedQuantifier); + ActivityUser user = new ActivityUser(); + /*double distanceFactorCm; + if (user.getGender() == user.GENDER_MALE){ + distanceFactorCm = user.getHeightCm() * user.GENDER_MALE_DISTANCE_FACTOR / 1000; + } else { + distanceFactorCm = user.getHeightCm() * user.GENDER_FEMALE_DISTANCE_FACTOR / 1000; + }*/ + + for (Map.Entry entry : analysis.stats.entrySet()) { + entries.add(new BarEntry(entry.getKey(), entry.getValue() / 60)); } BarDataSet set = new BarDataSet(entries, ""); @@ -83,14 +86,6 @@ public class StatsChartFragment extends AbstractChartFragment { //data.setBarWidth(0.1f); data.addDataSet(set); - // set X axis - customXAxis.sort(); - XAxis left = mStatsChart.getXAxis(); - left.setValueFormatter(customXAxis); - - // display precision - //mStatsChart.getDescription().setText(Math.round(analysis.roundPrecision * 100) + "%"); - return new MySpeedZonesData(data); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/XAxisValueFormatter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/XAxisValueFormatter.java deleted file mode 100644 index 30d875ea..00000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/XAxisValueFormatter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2017 Vebryn - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.activities.charts; - -import com.github.mikephil.charting.components.AxisBase; -import com.github.mikephil.charting.formatter.IAxisValueFormatter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Created by Vebryn on 30/04/17. - */ - -public class XAxisValueFormatter implements IAxisValueFormatter { - private static final Logger LOG = LoggerFactory.getLogger(XAxisValueFormatter.class); - private List mValues = new ArrayList<>(); - - public XAxisValueFormatter() { - super(); - } - - public void add(String label) { - mValues.add(label); - } - - public void sort() { - LOG.info("Sorting " + mValues); - Collections.sort(mValues); - } - - @Override - public String getFormattedValue(float value, AxisBase axis) { - String returnString = "N/A"; - - try { - returnString = mValues.get((int) value).toString(); - LOG.info("Asking " + value + ", returning " + returnString); - } catch (Exception e) { - LOG.error(e.getMessage()); - } - return returnString; - } -}