Java Code Examples for com.github.mikephil.charting.data.BarDataSet#setValueTextColor()

The following examples show how to use com.github.mikephil.charting.data.BarDataSet#setValueTextColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedChartActivity.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
private BarData generateBarData() {

        ArrayList<BarEntry> entries1 = new ArrayList<>();
        ArrayList<BarEntry> entries2 = new ArrayList<>();

        for (int index = 0; index < count; index++) {
            entries1.add(new BarEntry(0, getRandom(25, 25)));

            // stacked
            entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
        }

        BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
        set1.setColor(Color.rgb(60, 220, 78));
        set1.setValueTextColor(Color.rgb(60, 220, 78));
        set1.setValueTextSize(10f);
        set1.setAxisDependency(YAxis.AxisDependency.LEFT);

        BarDataSet set2 = new BarDataSet(entries2, "");
        set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
        set2.setColors(Color.rgb(61, 165, 255), Color.rgb(23, 197, 255));
        set2.setValueTextColor(Color.rgb(61, 165, 255));
        set2.setValueTextSize(10f);
        set2.setAxisDependency(YAxis.AxisDependency.LEFT);

        float groupSpace = 0.06f;
        float barSpace = 0.02f; // x2 dataset
        float barWidth = 0.45f; // x2 dataset
        // (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"

        BarData d = new BarData(set1, set2);
        d.setBarWidth(barWidth);

        // make this BarData object grouped
        d.groupBars(0, groupSpace, barSpace); // start at x = 0

        return d;
    }
 
Example 2
Source File: DailyBarChart.java    From AndroidApp with GNU Affero General Public License v3.0 5 votes vote down vote up
private BarData createDataSet() {
    ArrayList<BarEntry> entries = new ArrayList<>();
    BarData chart2_bardata = new BarData();
    BarDataSet chart2_dataset = new BarDataSet(entries, "kWh");
    chart2_dataset.setColor(ContextCompat.getColor(context, R.color.colorAccent));
    chart2_dataset.setValueTextColor(ContextCompat.getColor(context, R.color.lightGrey));
    chart2_dataset.setValueTextSize(context.getResources().getInteger(R.integer.chartValueTextSize));
    chart2_dataset.setValueFormatter(new Chart2ValueFormatter());
    chart2_bardata.addDataSet(chart2_dataset);
    barChart.setData(chart2_bardata);
    return chart2_bardata;
}
 
Example 3
Source File: Results.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
private void setDataS() {

        ArrayList<String> xVals = new ArrayList<String>();
        Collections.addAll(xVals, ltob);


        ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();

        for (int i = 0; i < splHistogram.size(); i++) {
            yVals1.add(new BarEntry(splHistogram.get(i), i));
        }

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
        set1.setValueTextColor(Color.WHITE);

        set1.setColors(
                new int[]{Color.rgb(0, 128, 255), Color.rgb(0, 128, 255), Color.rgb(0, 128, 255),
                        Color.rgb(102, 178, 255), Color.rgb(102, 178, 255),
                        Color.rgb(102, 178, 255)});

        ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
        dataSets.add(set1);

        BarData data = new BarData(xVals, dataSets);
        data.setValueTextSize(10f);
        data.setValueFormatter(new FreqValueFormater(sChart));
        sChart.setData(data);
        sChart.invalidate();
    }
 
Example 4
Source File: CombinedChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
private BarData generateBarData() {

        BarData d = new BarData();

        ArrayList<BarEntry> entries = new ArrayList<BarEntry>();

        for (int index = 0; index < itemcount; index++)
            entries.add(new BarEntry(getRandom(15, 30), index));

        BarDataSet set = new BarDataSet(entries, "Bar DataSet");
        set.setColor(Color.rgb(60, 220, 78));
        set.setValueTextColor(Color.rgb(60, 220, 78));
        set.setValueTextSize(10f);
        d.addDataSet(set);

        set.setAxisDependency(YAxis.AxisDependency.LEFT);

        return d;
    }
 
Example 5
Source File: CalibrationLinearityActivity.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
private void updateBarChart() {
    BarChart barChart = getBarChart();
    if(barChart == null) {
        return;
    }
    if(freqLeqStats.size() <= 2) {
        return;
    }
    double[] pearsons = computePearson();
    if(pearsons == null) {
        return;
    }

    float YMin = Float.MAX_VALUE;
    float YMax = Float.MIN_VALUE;

    ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();

    // Read all white noise values for indexing before usage
    ArrayList<BarEntry> yMeasure = new ArrayList<BarEntry>();
    int idfreq = 0;
    for (double value : pearsons) {
        YMax = Math.max(YMax, (float)value);
        YMin = Math.min(YMin, (float)value);
        yMeasure.add(new BarEntry((float)value, idfreq++));
    }
    BarDataSet freqSet = new BarDataSet(yMeasure, "Pearson's correlation");
    freqSet.setColor(ColorTemplate.COLORFUL_COLORS[0]);
    freqSet.setValueTextColor(Color.WHITE);
    freqSet.setDrawValues(true);
    dataSets.add(freqSet);


    ArrayList<String> xVals = new ArrayList<String>();
    double[] freqs = FFTSignalProcessing.computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION);
    for (double freqValue : freqs) {
        xVals.add(Spectrogram.formatFrequency((int)freqValue));
    }

    // create a data object with the datasets
    BarData data = new BarData(xVals, dataSets);
    barChart.setData(data);
    YAxis yl = barChart.getAxisLeft();
    yl.setAxisMinValue(YMin - 0.1f);
    yl.setAxisMaxValue(YMax + 0.1f);

    barChart.invalidate();
}