Merge pull request #1212 from elagin/legend_wordwrap_center

Enable word wrap and set center horizontal alignment for legend into …
This commit is contained in:
Carsten Pfeiffer
2018-08-16 23:58:00 +02:00
committed by GitHub
2 changed files with 6 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ import android.view.ViewGroup;
import com.github.mikephil.charting.animation.Easing;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.LegendEntry;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
@@ -177,6 +178,8 @@ public class ActivitySleepChartFragment extends AbstractChartFragment {
legendEntries.add(hrEntry);
}
chart.getLegend().setCustom(legendEntries);
chart.getLegend().setWordWrapEnabled(true);
chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
}
@Override

View File

@@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities.charts;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.LegendEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
@@ -132,5 +133,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
chart.getLegend().setCustom(legendEntries);
chart.getLegend().setTextColor(LEGEND_TEXT_COLOR);
chart.getLegend().setWordWrapEnabled(true);
chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
}
}