Fiix visal glitch in weeksteps chart (first and last bar only partly visible)
This commit is contained in:
parent
7479c3d420
commit
558c9e4664
|
@ -11,6 +11,7 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.view.View;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.components.AxisBase;
|
||||
|
@ -18,6 +19,7 @@ import com.github.mikephil.charting.components.YAxis;
|
|||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
|
@ -360,6 +362,9 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||
|
||||
protected void configureBarLineChartDefaults(BarLineChartBase<?> chart) {
|
||||
configureChartDefaults(chart);
|
||||
if (chart instanceof BarChart) {
|
||||
((BarChart) chart).setFitBars(true);
|
||||
}
|
||||
|
||||
// enable scaling and dragging
|
||||
chart.setDragEnabled(true);
|
||||
|
@ -712,16 +717,16 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||
return (int) ((date.getTime() / 1000));
|
||||
}
|
||||
|
||||
public static class DefaultChartsData extends ChartsData {
|
||||
private final CombinedData combinedData;
|
||||
public static class DefaultChartsData<T extends ChartData<?>> extends ChartsData {
|
||||
private final T data;
|
||||
|
||||
public DefaultChartsData(CombinedData combinedData, ArrayList<String> xLabels) {
|
||||
this.combinedData = combinedData;
|
||||
public DefaultChartsData(T data, ArrayList<String> xLabels) {
|
||||
this.data = data;
|
||||
setxLabels(xLabels);
|
||||
}
|
||||
|
||||
public CombinedData getCombinedData() {
|
||||
return combinedData;
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import com.github.mikephil.charting.charts.Chart;
|
|||
import com.github.mikephil.charting.components.LegendEntry;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -120,7 +119,7 @@ public class ActivitySleepChartFragment extends AbstractChartFragment {
|
|||
mChart.getLegend().setTextColor(LEGEND_TEXT_COLOR);
|
||||
mChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
||||
xIndexFormatter.setxLabels(dcd.getXLabels());
|
||||
mChart.setData(dcd.getCombinedData());
|
||||
mChart.setData(dcd.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.github.mikephil.charting.charts.PieChart;
|
|||
import com.github.mikephil.charting.components.LegendEntry;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
|
@ -101,7 +102,7 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||
|
||||
mActivityChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
||||
xIndexFormatter.setxLabels(mcd.getChartsData().getXLabels());
|
||||
mActivityChart.setData(mcd.getChartsData().getCombinedData());
|
||||
mActivityChart.setData(mcd.getChartsData().getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -239,10 +240,10 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||
}
|
||||
|
||||
private static class MyChartsData extends ChartsData {
|
||||
private final DefaultChartsData chartsData;
|
||||
private final DefaultChartsData<CombinedData> chartsData;
|
||||
private final MySleepChartsData pieData;
|
||||
|
||||
public MyChartsData(MySleepChartsData pieData, DefaultChartsData chartsData) {
|
||||
public MyChartsData(MySleepChartsData pieData, DefaultChartsData<CombinedData> chartsData) {
|
||||
this.pieData = pieData;
|
||||
this.chartsData = chartsData;
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||
return pieData;
|
||||
}
|
||||
|
||||
public DefaultChartsData getChartsData() {
|
||||
public DefaultChartsData<CombinedData> getChartsData() {
|
||||
return chartsData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.CombinedChart;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.components.LimitLine;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
|
@ -15,7 +15,6 @@ import com.github.mikephil.charting.components.YAxis;
|
|||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
|
@ -43,7 +42,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
private int mTargetSteps = 10000;
|
||||
|
||||
private PieChart mTodayStepsChart;
|
||||
private CombinedChart mWeekStepsChart;
|
||||
private BarChart mWeekStepsChart;
|
||||
|
||||
@Override
|
||||
protected ChartsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||
|
@ -65,7 +64,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
mTodayStepsChart.setData(mcd.getDaySteps().data);
|
||||
|
||||
mWeekStepsChart.setData(null); // workaround for https://github.com/PhilJay/MPAndroidChart/issues/2317
|
||||
mWeekStepsChart.setData(mcd.getWeekBeforeStepsData().getCombinedData());
|
||||
mWeekStepsChart.setData(mcd.getWeekBeforeStepsData().getData());
|
||||
mWeekStepsChart.getLegend().setEnabled(false);
|
||||
xIndexFormatter.setxLabels(mcd.getWeekBeforeStepsData().getXLabels());
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
mTodayStepsChart.invalidate();
|
||||
}
|
||||
|
||||
private DefaultChartsData refreshWeekBeforeSteps(DBHandler db, CombinedChart combinedChart, Calendar day, GBDevice device) {
|
||||
private DefaultChartsData refreshWeekBeforeSteps(DBHandler db, BarChart barChart, Calendar day, GBDevice device) {
|
||||
|
||||
ActivityAnalysis analysis = new ActivityAnalysis();
|
||||
|
||||
|
@ -98,16 +97,13 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
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);
|
||||
|
||||
LimitLine target = new LimitLine(mTargetSteps);
|
||||
combinedChart.getAxisLeft().removeAllLimitLines();
|
||||
combinedChart.getAxisLeft().addLimitLine(target);
|
||||
barChart.getAxisLeft().removeAllLimitLines();
|
||||
barChart.getAxisLeft().addLimitLine(target);
|
||||
|
||||
CombinedData combinedData = new CombinedData();
|
||||
combinedData.setData(barData);
|
||||
return new DefaultChartsData(combinedData, labels);
|
||||
return new DefaultChartsData(barData, labels);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private DaySteps refreshDaySteps(DBHandler db, Calendar day, GBDevice device) {
|
||||
ActivityAnalysis analysis = new ActivityAnalysis();
|
||||
|
||||
|
@ -139,7 +135,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
Bundle savedInstanceState) {
|
||||
mLocale = getResources().getConfiguration().locale;
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_sleepchart, container, false);
|
||||
View rootView = inflater.inflate(R.layout.fragment_weeksteps_chart, container, false);
|
||||
|
||||
GBDevice device = getChartsHost().getDevice();
|
||||
if (device != null) {
|
||||
|
@ -147,8 +143,8 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
mTargetSteps = MiBandCoordinator.getFitnessGoal(device.getAddress());
|
||||
}
|
||||
|
||||
mWeekStepsChart = (CombinedChart) rootView.findViewById(R.id.sleepchart);
|
||||
mTodayStepsChart = (PieChart) rootView.findViewById(R.id.sleepchart_pie_light_deep);
|
||||
mTodayStepsChart = (PieChart) rootView.findViewById(R.id.todaystepschart);
|
||||
mWeekStepsChart = (BarChart) rootView.findViewById(R.id.weekstepschart);
|
||||
|
||||
setupWeekStepsChart();
|
||||
setupTodayStepsChart();
|
||||
|
@ -178,6 +174,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
mWeekStepsChart.setBackgroundColor(BACKGROUND_COLOR);
|
||||
mWeekStepsChart.getDescription().setTextColor(DESCRIPTION_COLOR);
|
||||
mWeekStepsChart.getDescription().setText("");
|
||||
mWeekStepsChart.setFitBars(true);
|
||||
|
||||
configureBarLineChartDefaults(mWeekStepsChart);
|
||||
|
||||
|
@ -251,10 +248,10 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
}
|
||||
|
||||
private static class MyChartsData extends ChartsData {
|
||||
private final DefaultChartsData weekBeforeStepsData;
|
||||
private final DefaultChartsData<BarData> weekBeforeStepsData;
|
||||
private final DaySteps daySteps;
|
||||
|
||||
public MyChartsData(DaySteps daySteps, DefaultChartsData weekBeforeStepsData) {
|
||||
public MyChartsData(DaySteps daySteps, DefaultChartsData<BarData> weekBeforeStepsData) {
|
||||
this.daySteps = daySteps;
|
||||
this.weekBeforeStepsData = weekBeforeStepsData;
|
||||
}
|
||||
|
@ -263,7 +260,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
|
|||
return daySteps;
|
||||
}
|
||||
|
||||
public DefaultChartsData getWeekBeforeStepsData() {
|
||||
public DefaultChartsData<BarData> getWeekBeforeStepsData() {
|
||||
return weekBeforeStepsData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity$PlaceholderFragment"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.github.mikephil.charting.charts.PieChart
|
||||
android:id="@+id/todaystepschart"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="40">
|
||||
</com.github.mikephil.charting.charts.PieChart>
|
||||
|
||||
<com.github.mikephil.charting.charts.BarChart
|
||||
android:id="@+id/weekstepschart"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
|
||||
android:layout_weight="20" />
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:text="Test"-->
|
||||
<!--android:layout_width="fill_parent"-->
|
||||
<!--android:layout_height="fill_parent"-->
|
||||
<!--android:layout_weight="20" />-->
|
||||
|
||||
</LinearLayout>
|
|
@ -18,10 +18,4 @@
|
|||
|
||||
android:layout_weight="20" />
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:text="Test"-->
|
||||
<!--android:layout_width="fill_parent"-->
|
||||
<!--android:layout_height="fill_parent"-->
|
||||
<!--android:layout_weight="20" />-->
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity$PlaceholderFragment"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.mikephil.charting.charts.PieChart
|
||||
android:id="@+id/todaystepschart"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="20">
|
||||
</com.github.mikephil.charting.charts.PieChart>
|
||||
|
||||
<com.github.mikephil.charting.charts.BarChart
|
||||
android:id="@+id/weekstepschart"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
|
||||
android:layout_weight="20" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue