use of com.github.mikephil.charting.data.BarData in project Gadgetbridge by Freeyourgadget.
the class AbstractWeekChartFragment method refreshWeekBeforeData.
private DefaultChartsData<BarData> refreshWeekBeforeData(DBHandler db, BarChart barChart, Calendar day, GBDevice device) {
// do not modify the caller's argument
day = (Calendar) day.clone();
day.add(Calendar.DATE, -7);
List<BarEntry> entries = new ArrayList<>();
ArrayList<String> labels = new ArrayList<String>();
for (int counter = 0; counter < 7; counter++) {
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
entries.add(new BarEntry(counter, getTotalsForActivityAmounts(amounts)));
labels.add(day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale));
day.add(Calendar.DATE, 1);
}
BarDataSet set = new BarDataSet(entries, "");
set.setColors(getColors());
set.setValueFormatter(getBarValueFormatter());
BarData barData = new BarData(set);
//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);
LimitLine target = new LimitLine(mTargetValue);
barChart.getAxisLeft().removeAllLimitLines();
barChart.getAxisLeft().addLimitLine(target);
return new DefaultChartsData(barData, new PreformattedXIndexLabelFormatter(labels));
}
use of com.github.mikephil.charting.data.BarData in project LeMondeRssReader by MBach.
the class GraphExtractor method generate.
Object generate() {
BarChart barChart = new BarChart(context);
List<BarEntry> yVals1 = new ArrayList<>();
for (int i = 0; i < 30; i++) {
float mult = 5;
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(i, val));
}
BarDataSet set1 = new BarDataSet(yVals1, "The year 2017");
List<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData barData = new BarData(dataSets);
barChart.setData(barData);
return barChart;
}
Aggregations