Search in sources :

Example 21 with BarDataSet

use of com.github.mikephil.charting.data.BarDataSet in project Gadgetbridge by Freeyourgadget.

the class AbstractChartFragment method createLightSleepSet.

protected BarDataSet createLightSleepSet(List<BarEntry> values, String label) {
    BarDataSet set1 = new BarDataSet(values, label);
    //        set1.setDrawCubic(true);
    //        set1.setCubicIntensity(0.2f);
    //        //set1.setDrawFilled(true);
    //        set1.setDrawCircles(false);
    //        set1.setLineWidth(2f);
    //        set1.setCircleSize(5f);
    //        set1.setFillColor(ColorTemplate.getHoloBlue());
    set1.setDrawValues(false);
    //        set1.setHighLightColor(Color.rgb(244, 117, 117));
    //        set1.setColor(Color.rgb(182, 191, 255));
    set1.setValueTextColor(CHART_TEXT_COLOR);
    //        set1.setColor(Color.CYAN);
    return set1;
}
Also used : BarDataSet(com.github.mikephil.charting.data.BarDataSet) IBarDataSet(com.github.mikephil.charting.interfaces.datasets.IBarDataSet)

Example 22 with BarDataSet

use of com.github.mikephil.charting.data.BarDataSet in project Gadgetbridge by Freeyourgadget.

the class AbstractChartFragment method createActivitySet.

protected BarDataSet createActivitySet(List<BarEntry> values, List<Integer> colors, String label) {
    BarDataSet set1 = new BarDataSet(values, label);
    set1.setColors(colors);
    //        set1.setDrawCubic(true);
    //        set1.setCubicIntensity(0.2f);
    //        //set1.setDrawFilled(true);
    //        set1.setDrawCircles(false);
    //        set1.setLineWidth(2f);
    //        set1.setCircleSize(5f);
    //        set1.setFillColor(ColorTemplate.getHoloBlue());
    set1.setDrawValues(false);
    //        set1.setHighLightColor(Color.rgb(128, 0, 255));
    //        set1.setColor(Color.rgb(89, 178, 44));
    set1.setValueTextColor(CHART_TEXT_COLOR);
    set1.setAxisDependency(YAxis.AxisDependency.LEFT);
    return set1;
}
Also used : BarDataSet(com.github.mikephil.charting.data.BarDataSet) IBarDataSet(com.github.mikephil.charting.interfaces.datasets.IBarDataSet)

Example 23 with BarDataSet

use of com.github.mikephil.charting.data.BarDataSet 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;
}
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) BarChart(com.github.mikephil.charting.charts.BarChart) ArrayList(java.util.ArrayList) BarEntry(com.github.mikephil.charting.data.BarEntry)

Example 24 with BarDataSet

use of com.github.mikephil.charting.data.BarDataSet in project Thrift-box by Sash0k.

the class ChartsFragment method generateMonthlyData.

// ============================================================================
/**
 * Заполнение графика данными
 */
private BarData generateMonthlyData() {
    final Context ctx = getActivity();
    // получение категорий
    final String[] bars = ctx.getResources().getStringArray(R.array.categories);
    // получение данных
    final long month = getArguments().getLong(DB.TIMESTAMP);
    // Статистика за текущий месяц
    List<Float> stats = new DB(ctx).getStatData(ctx, month, bars.length);
    final int count = stats.size();
    ArrayList<BarEntry> entries = new ArrayList<>();
    final ArrayList<String> usedBars = new ArrayList<>();
    int j = 0;
    for (int i = 0; i < count; i++) {
        float value = stats.get(i);
        if (value > 0f) {
            usedBars.add(bars[i]);
            entries.add(new BarEntry(value, j, bars[i]));
            j++;
        }
    }
    // данные графика
    BarDataSet ds = new BarDataSet(entries, null);
    ds.setDrawValues(true);
    ds.setColor(getResources().getColor(R.color.accent));
    // подписи к линиям графика
    BarData d = new BarData(usedBars, ds);
    d.setValueTextColor(getResources().getColor(R.color.primary_text));
    d.setValueTextSize(14f);
    d.setValueFormatter(new FinanceFormatter());
    return d;
}
Also used : Context(android.content.Context) BarDataSet(com.github.mikephil.charting.data.BarDataSet) ArrayList(java.util.ArrayList) BarEntry(com.github.mikephil.charting.data.BarEntry) Paint(android.graphics.Paint) FinanceFormatter(ru.sash0k.thriftbox.charting.FinanceFormatter) BarData(com.github.mikephil.charting.data.BarData) DB(ru.sash0k.thriftbox.database.DB)

Example 25 with BarDataSet

use of com.github.mikephil.charting.data.BarDataSet in project android by lucadln.

the class ScoreChart method disposeHorizontalBarChart.

/**
 * Method to set data and design for the bar chart
 */
public void disposeHorizontalBarChart(float[] scores, int[] correctConjugationsCount, int[] totalConjugationsCount) {
    /* Set a custom renderer. This helps to show chart labels either
         *   inside or outside the chart bars depending on their values */
    barChart.setRenderer(new CustomHorizontalBarChartRenderer(barChart, barChart.getAnimator(), barChart.getViewPortHandler(), scores));
    barChart.invalidate();
    // Add entry values for every tense
    ArrayList<BarEntry> barEntries = new ArrayList<>();
    for (int i = 0; i < tenses.length; i++) {
        barEntries.add(new BarEntry((float) i, scores[i]));
    }
    // Create a data set from the entry values
    BarDataSet dataSet = new BarDataSet(barEntries, "Tenses");
    // Set data set values to be visible on the graph
    dataSet.setDrawValues(true);
    // Create a data object from the data set
    BarData data = new BarData(dataSet);
    // Set the width of the bars
    data.setBarWidth(0.68f);
    // Make the chart use the acquired data
    barChart.setData(data);
    // Display data as <correctAnswers>/<totalAnswers>
    data.setValueFormatter(new CustomValueFormatter(correctConjugationsCount, totalConjugationsCount));
    // Create explanation labels for each bar
    final ArrayList<String> barLabels = new ArrayList<>();
    barLabels.add("Present");
    barLabels.add("Pres. Perfect");
    barLabels.add("Simple Past");
    barLabels.add("Past Perfect");
    barLabels.add("Conditional");
    barLabels.add("Cond. Perfect");
    barLabels.add("Future");
    // Display explanation labels
    barChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(barLabels));
    // Set the minimum and maximum bar values
    barChart.getAxisLeft().setAxisMaximum(100);
    barChart.getAxisLeft().setAxisMinimum(0);
    // Set a color for each bar in the chart based on its value
    setBarChartColors(scores);
    // Animate chart so that bars are sliding from left to right
    barChart.animateXY(1000, 1000);
    // Hide grid lines
    barChart.getAxisLeft().setEnabled(false);
    barChart.getAxisRight().setEnabled(false);
    // Hide graph description
    barChart.getDescription().setEnabled(false);
    // Hide graph legend
    barChart.getLegend().setEnabled(false);
    // Set colors and font style
    dataSet.setColors(colors);
    data.setValueTextSize(13f);
    data.setValueTextColor(Color.DKGRAY);
}
Also used : BarDataSet(com.github.mikephil.charting.data.BarDataSet) BarData(com.github.mikephil.charting.data.BarData) ArrayList(java.util.ArrayList) IndexAxisValueFormatter(com.github.mikephil.charting.formatter.IndexAxisValueFormatter) BarEntry(com.github.mikephil.charting.data.BarEntry)

Aggregations

BarDataSet (com.github.mikephil.charting.data.BarDataSet)41 ArrayList (java.util.ArrayList)27 BarEntry (com.github.mikephil.charting.data.BarEntry)25 BarData (com.github.mikephil.charting.data.BarData)24 IBarDataSet (com.github.mikephil.charting.interfaces.datasets.IBarDataSet)22 Intent (android.content.Intent)8 Paint (android.graphics.Paint)5 List (java.util.List)4 SuppressLint (android.annotation.SuppressLint)2 XAxis (com.github.mikephil.charting.components.XAxis)2 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)2 IDataSet (com.github.mikephil.charting.interfaces.datasets.IDataSet)2 Context (android.content.Context)1 Path (android.graphics.Path)1 PointF (android.graphics.PointF)1 RectF (android.graphics.RectF)1 BarChart (com.github.mikephil.charting.charts.BarChart)1 AxisBase (com.github.mikephil.charting.components.AxisBase)1 Legend (com.github.mikephil.charting.components.Legend)1 LimitLine (com.github.mikephil.charting.components.LimitLine)1