Search in sources :

Example 1 with StackedValueFormatter

use of com.github.mikephil.charting.formatter.StackedValueFormatter in project openScale by oliexdev.

the class GraphFragment method generateColumnData.

private void generateColumnData() {
    int[] numOfMonth = openScale.getCountsOfMonth(calYears.getYear());
    LocalDate calMonths = LocalDate.of(calYears.getYear(), 1, 1);
    List<IBarDataSet> dataSets = new ArrayList<>();
    for (int i = 0; i < 12; i++) {
        List<BarEntry> entries = new ArrayList<>();
        entries.add(new BarEntry(calMonths.getMonthValue() - 1, numOfMonth[i]));
        calMonths = calMonths.plusMonths(1);
        BarDataSet set = new BarDataSet(entries, "month " + i);
        set.setColor(ColorUtil.COLORS[i % 4]);
        set.setDrawValues(false);
        set.setValueFormatter(new StackedValueFormatter(true, "", 0));
        dataSets.add(set);
    }
    BarData data = new BarData(dataSets);
    chartTop.setData(data);
    chartTop.setFitBars(true);
    chartTop.invalidate();
}
Also used : BarDataSet(com.github.mikephil.charting.data.BarDataSet) IBarDataSet(com.github.mikephil.charting.interfaces.datasets.IBarDataSet) BarData(com.github.mikephil.charting.data.BarData) IBarDataSet(com.github.mikephil.charting.interfaces.datasets.IBarDataSet) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) BarEntry(com.github.mikephil.charting.data.BarEntry) StackedValueFormatter(com.github.mikephil.charting.formatter.StackedValueFormatter)

Aggregations

BarData (com.github.mikephil.charting.data.BarData)1 BarDataSet (com.github.mikephil.charting.data.BarDataSet)1 BarEntry (com.github.mikephil.charting.data.BarEntry)1 StackedValueFormatter (com.github.mikephil.charting.formatter.StackedValueFormatter)1 IBarDataSet (com.github.mikephil.charting.interfaces.datasets.IBarDataSet)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1