Skip to content

Commit

Permalink
Closes #123
Browse files Browse the repository at this point in the history
Merge branch 'fix/stage-graph' into develop

* fix/stage-graph:
  Fixes stage chart issues
  • Loading branch information
7LPdWcaW committed Sep 26, 2019
2 parents 1f8ae38 + abbff78 commit 989b8eb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import androidx.fragment.app.Fragment;
import me.anon.grow.R;
import me.anon.lib.Views;
import me.anon.lib.ext.IntUtilsKt;
import me.anon.lib.helper.StatsHelper;
import me.anon.lib.helper.TimeHelper;
import me.anon.model.Action;
Expand Down Expand Up @@ -342,7 +343,7 @@ private void setStatistics()
for (PlantStage plantStage : stages.keySet())
{
yVals[index] = Math.max((float)(int)TimeHelper.toDays(stages.get(plantStage)), 1f);
labels[index--] = plantStage.name();
labels[index--] = getString(plantStage.getPrintString());
}

entry.add(new BarEntry(yVals, 0));
Expand All @@ -351,14 +352,15 @@ private void setStatistics()
set.setColors(statsColours);
set.setStackLabels(labels);
set.setValueTextSize(12.0f);
set.setValueTextColor(IntUtilsKt.resolveColor(R.attr.chart_label, getActivity()));
set.setHighlightEnabled(false);

BarData data = new BarData(new String[] { plant.getName() }, set);
BarData data = new BarData(new String[] { "" }, set);
data.setValueFormatter(new ValueFormatter()
{
@Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler)
{
return String.format("%s", "" + (int)value);
return (int)value + getString(R.string.day_abbr);
}
});

Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/layout/statistics_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@
/>
</LinearLayout>
</LinearLayout>

<com.github.mikephil.charting.charts.HorizontalBarChart
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="@+id/stage_chart"
android:layout_marginTop="16dp"
/>
</LinearLayout>

<com.github.mikephil.charting.charts.HorizontalBarChart
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="@+id/stage_chart"
android:layout_marginBottom="16dp"
/>
</LinearLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<item name="colorOnSecondary">#97FFFFFF</item>
<item name="colorControlNormal">#555555</item>
<item name="colorSurface">#242424</item>
<item name="chart_label">#BEFFFFFF</item>
<item name="android:windowBackground">@drawable/dark_window</item>
<item name="windowActionModeOverlay">true</item>
</style>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>
<attr name="chart_label" format="color" />
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<item name="colorSecondary">#ffb71c1c</item>
<item name="colorControlNormal">#4AA74E</item>
<item name="colorOnSecondary">#ffffff</item>
<item name="chart_label">#000000</item>

<item name="actionModeBackground">?colorPrimary</item>
<item name="android:actionModeBackground">?colorPrimary</item>
Expand Down

0 comments on commit 989b8eb

Please sign in to comment.