com.github.mikephil.charting.data.BarDataSet Java Examples

The following examples show how to use com.github.mikephil.charting.data.BarDataSet. 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: MainActivity.java    From AndroidDatabaseLibraryComparison with MIT License 6 votes vote down vote up
private void initChart() {
    ArrayList<BarDataSet> dataSets = new ArrayList<>();
    // note that we show save first because that's how we initialize the DB
    for (String frameworkName : chartEntrySets.keySet()) {
        ArrayList<BarEntry> entrySet = chartEntrySets.get(frameworkName);
        BarDataSet dataSet = new BarDataSet(entrySet, frameworkName);
        dataSet.setColor(getFrameworkColor(frameworkName));
        dataSets.add(dataSet);
    }
    // load data and animate it
    ArrayList<String> xAxisLabels = new ArrayList<>();
    xAxisLabels.add("Save (msec)");
    xAxisLabels.add("Load (msec)");
    BarData data = new BarData(xAxisLabels, dataSets);
    chartView.setData(data);
    chartView.setDescription(null); // this takes up too much space, so clear it
    chartView.animateXY(2000, 2000);
    chartView.invalidate();
}
 
Example #2
Source File: ScrollViewActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
private void setData(int count) {

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

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * count) + 15;
            values.add(new BarEntry(i, (int) val));
        }

        BarDataSet set = new BarDataSet(values, "Data Set");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setDrawValues(false);

        BarData data = new BarData(set);

        chart.setData(data);
        chart.invalidate();
        chart.animateY(800);
    }
 
Example #3
Source File: GraphLayout.java    From voice-pitch-analyzer with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * get bar chart data for male/female vocal ranges
 * to display them as bars beneath other chart data
 *
 * @param amount amount of entries needed
 * @return bar data to add to chart
 */
public static BarDataSet getOverallRange(Context context, int amount)
{
    BarDataSet set = new BarDataSet(GraphLayout.getRangeEntries(amount), "");
    set.setDrawValues(false);
    set.setColors(new int[]{context.getResources().getColor(R.color.male_range),
                            context.getResources().getColor(R.color.androgynous_range),
                            context.getResources().getColor(R.color.female_range)});
    set.setStackLabels(new String[]{context.getResources().getString(R.string.male_range),
                                    context.getResources().getString(R.string.androgynous_range),
                                    context.getResources().getString(R.string.female_range)
    });

    //        List<BarDataSet> setList = new ArrayList<BarDataSet>();
    //        setList.add(set);
    //
    //        return setList;

    return set;
}
 
Example #4
Source File: StatisticsFragment.java    From Expense-Tracker-App with MIT License 6 votes vote down vote up
private void setCategoriesBarChart() {
    List<String> categoriesNames = new ArrayList<>();
    List<BarEntry> entryPerCategory = new ArrayList<>();

    for (int i=0; i < mCategoryList.size(); i++) {
        float value = Expense.getCategoryTotalByDate(DateManager.getInstance().getDateFrom(), DateManager.getInstance().getDateTo(), mCategoryList.get(i));
        if (value > 0) {
            categoriesNames.add(mCategoryList.get(i).getName());
            entryPerCategory.add(new BarEntry(value, categoriesNames.size()-1));
        }
    }
    if (categoriesNames.isEmpty()) {
        tvBcCategoriesEmpty.setVisibility(View.VISIBLE);
        bcCategories.setVisibility(View.GONE);
    } else {
        tvBcCategoriesEmpty.setVisibility(View.GONE);
        bcCategories.setVisibility(View.VISIBLE);
    }
    BarDataSet dataSet = new BarDataSet(entryPerCategory, getString(R.string.categories));
    dataSet.setColors(Util.getListColors());
    BarData barData = new BarData(categoriesNames, dataSet);
    bcCategories.setData(barData);
    bcCategories.invalidate();
}
 
Example #5
Source File: SimpleFragment.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
protected BarData generateBarData(int dataSets, float range, int count) {

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

        for(int i = 0; i < dataSets; i++) {

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

            for(int j = 0; j < count; j++) {
                entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
            }

            BarDataSet ds = new BarDataSet(entries, getLabel(i));
            ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
            sets.add(ds);
        }

        BarData d = new BarData(sets);
        d.setValueTypeface(tf);
        return d;
    }
 
Example #6
Source File: ListViewBarChartActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return Bar data
 */
private BarData generateData(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setBarShadowColor(Color.rgb(203, 203, 203));

    ArrayList<IBarDataSet> sets = new ArrayList<>();
    sets.add(d);

    BarData cd = new BarData(sets);
    cd.setBarWidth(0.9f);
    return cd;
}
 
Example #7
Source File: StatisticsFragment.java    From HeartBeat with Apache License 2.0 6 votes vote down vote up
private BarData getWeekEventData() {
    BarData d = new BarData();

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

    for (int i=0; i<WEEK_COUNT; i++) {
        entries.add(
                new BarEntry(
                        new GetCountSpecDayApi(getActivity()).exec(
                                TimeUtils.calendarDaysBefore(WEEK_COUNT-i),
                                GetCountSpecDayApi.EVENT
                        ),i
                )
        );
    }

    BarDataSet set = new BarDataSet(entries, getString(R.string.event_count_text));
    set.setColor(mPrimaryColorDark);
    set.setValueFormatter(new IntValueFormatter());
    d.addDataSet(set);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    return d;
}
 
Example #8
Source File: BarChart.java    From Notification-Analyser with MIT License 6 votes vote down vote up
/**
 * Returns the bounding box of the specified Entry in the specified DataSet.
 * Returns null if the Entry could not be found in the charts data.
 * 
 * @param e
 * @param dataSetIndex
 * @return
 */
public RectF getBarBounds(BarEntry e) {

    BarDataSet set = mOriginalData.getDataSetForEntry(e);

    if (set == null)
        return null;

    float barspace = set.getBarSpace();
    float y = e.getVal();
    float x = e.getXIndex();

    float spaceHalf = barspace / 2f;
    float left = x + spaceHalf;
    float right = x + 1f - spaceHalf;
    float top = y >= 0 ? y : 0;
    float bottom = y <= 0 ? y : 0;

    RectF bounds = new RectF(left, top, right, bottom);

    transformRect(bounds);

    return bounds;
}
 
Example #9
Source File: StatisticActivity.java    From memorize with MIT License 6 votes vote down vote up
private BarData generateDataBar(int cnt) {

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

        for (int i = 0; i < 12; i++) {
            entries.add(new BarEntry(i, (int) (Math.random() * 70) + 30));
        }

        BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
        d.setColors(ColorTemplate.VORDIPLOM_COLORS);
        d.setHighLightAlpha(255);

        BarData cd = new BarData(d);
        cd.setBarWidth(0.9f);
        return cd;
    }
 
Example #10
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 6 votes vote down vote up
private void setData(double val) {

        ArrayList<String> xVals = new ArrayList<String>();
        xVals.add("");

        ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
        yVals1.add(new BarEntry((float)val, 0));

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
        //set1.setBarSpacePercent(35f);
        //set1.setColor(Color.rgb(0, 153, 204));
        int nc=getNEcatColors(val);    // Choose the color category in function of the sound level
        set1.setColor(NE_COLORS[nc]);

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

        BarData data = new BarData(xVals, dataSets);
        data.setValueTextSize(10f);

        mChart.setData(data);
        mChart.invalidate(); // refresh
    }
 
Example #11
Source File: ListViewMultiChartActivity.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 *
 * @return Bar data
 */
private BarData generateDataBar(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry(i, (int) (Math.random() * 70) + 30));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setHighLightAlpha(255);

    BarData cd = new BarData(d);
    cd.setBarWidth(0.9f);
    return cd;
}
 
Example #12
Source File: BarLineChartBase.java    From Notification-Analyser with MIT License 6 votes vote down vote up
/**
 * Returns the position (in pixels) the provided Entry has inside the chart
 * view or null, if the provided Entry is null.
 * 
 * @param e
 * @return
 */
public PointF getPosition(Entry e) {

    if (e == null)
        return null;

    float[] vals = new float[] {
            e.getXIndex(), e.getVal()
    };

    if (this instanceof BarChart) {

        BarDataSet set = (BarDataSet) mOriginalData.getDataSetForEntry(e);
        if (set != null)
            vals[0] += set.getBarSpace() / 2f;
    }

    transformPointArray(vals);

    return new PointF(vals[0], vals[1]);
}
 
Example #13
Source File: DailyBarChart.java    From AndroidApp with GNU Affero General Public License v3.0 6 votes vote down vote up
public void refreshChart(int start) {

        BarDataSet dataSet = (BarDataSet) barData.getDataSetByLabel("kWh", true);
        dataSet.clear();
        if (chartBarColours != null) {
            dataSet.setColors(chartBarColours);
        }

        for (int i = start; i < chartLabels.size(); i++) {
            barData.addEntry(new BarEntry(i, chartValues.get(i).floatValue()), 0);
        }
        XAxis xAxis2 = barChart.getXAxis();
        xAxis2.setValueFormatter(new LabelAxisFormatter(chartLabels));
        barChart.getXAxis().setLabelCount(chartLabels.size());
        notifyDataChanged();

    }
 
Example #14
Source File: ProductDetailActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
public BarData getBarData() {

        ArrayList<BarEntry> entries = new ArrayList<>();
        float overall_people = 100f;

        Log.d(TAG + "barData", barRatingCount[3] + "");
        entries.add(new BarEntry(4, barRatingCount[4]));
        entries.add(new BarEntry(3, barRatingCount[3]));
        entries.add(new BarEntry(2, barRatingCount[2]));
        entries.add(new BarEntry(1, barRatingCount[1]));
        entries.add(new BarEntry(0, barRatingCount[0]));

        BarDataSet dataset = new BarDataSet(entries, "");
        dataset.setColors(CUSTOM_COLOR);
        dataset.setDrawValues(false);

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

        BarData data = new BarData(dataSets);
//        data.setValueTextSize(10f);
//        data.setValueTypeface(fontType);
        data.setBarWidth(1f);

        return data;
    }
 
Example #15
Source File: BarChartManager.java    From react-native-mp-android-chart with MIT License 6 votes vote down vote up
@Override
void dataSetConfig(IDataSet<BarEntry> dataSet, ReadableMap config) {
    BarDataSet barDataSet = (BarDataSet) dataSet;

    ChartDataSetConfigUtils.commonConfig(barDataSet, config);
    ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(barDataSet, config);

    if (BridgeUtils.validate(config, ReadableType.Number, "barSpacePercent")) {
        barDataSet.setBarSpacePercent((float) config.getDouble("barSpacePercent"));
    }
    if (BridgeUtils.validate(config, ReadableType.String, "barShadowColor")) {
        barDataSet.setBarShadowColor(Color.parseColor(config.getString("barShadowColor")));
    }
    if (BridgeUtils.validate(config, ReadableType.Number, "highlightAlpha")) {
        barDataSet.setHighLightAlpha(config.getInt("highlightAlpha"));
    }
    if (BridgeUtils.validate(config, ReadableType.Array, "stackLabels")) {
        barDataSet.setStackLabels(BridgeUtils.convertToStringArray(config.getArray("stackLabels")));
    }
}
 
Example #16
Source File: BarChart.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
 * found in the charts data.
 * 
 * @param e
 * @return
 */
public RectF getBarBounds(BarEntry e) {

	BarDataSet set = mData.getDataSetForEntry(e);

	if (set == null)
		return null;

	float barspace = set.getBarSpace();
	float y = e.getVal();
	float x = e.getXIndex();

	float barWidth = 0.5f;

	float spaceHalf = barspace / 2f;
	float left = x - barWidth + spaceHalf;
	float right = x + barWidth - spaceHalf;
	float top = y >= 0 ? y : 0;
	float bottom = y <= 0 ? y : 0;

	RectF bounds = new RectF(left, top, right, bottom);

	getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

	return bounds;
}
 
Example #17
Source File: HorizontalBarChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData(int count, float range) {

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

        for (int i = 0; i < count; i++) {
            xVals.add(mMonths[i % 12]);
            yVals1.add(new BarEntry((float) (Math.random() * range), i));
        }

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1");

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

        BarData data = new BarData(xVals, dataSets);
        data.setValueTextSize(10f);
        data.setValueTypeface(tf);

        mChart.setData(data);
    }
 
Example #18
Source File: ScrollViewActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData(int count) {
    
    ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < count; i++) {
        float val = (float) (Math.random() * count) + 15;
        yVals.add(new BarEntry((int) val, i));
        xVals.add((int) val + "");
    }

    BarDataSet set = new BarDataSet(yVals, "Data Set");
    set.setColors(ColorTemplate.VORDIPLOM_COLORS);
    set.setDrawValues(false);

    BarData data = new BarData(xVals, set);

    mChart.setData(data);
    mChart.invalidate();
    mChart.animateY(800);
}
 
Example #19
Source File: ListViewMultiChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private BarData generateDataBar(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
    d.setBarSpacePercent(20f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setHighLightAlpha(255);
    
    BarData cd = new BarData(getMonths(), d);
    return cd;
}
 
Example #20
Source File: BarChartActivitySinus.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData(int count) {

        ArrayList<String> xVals = new ArrayList<String>();
        
        ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
        
        for (int i = 0; i < count; i++) {
            xVals.add(i+"");
            entries.add(mSinusData.get(i));
        }
        
        BarDataSet set = new BarDataSet(entries, "Sinus Function");
        set.setBarSpacePercent(40f);
        set.setColor(Color.rgb(240, 120, 124));

        BarData data = new BarData(xVals, set);
        data.setValueTextSize(10f);
        data.setValueTypeface(mTf);
        data.setDrawValues(false);

        mChart.setData(data);
    }
 
Example #21
Source File: ListViewBarChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private BarData generateData(int cnt) {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);    
    d.setBarSpacePercent(20f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    d.setBarShadowColor(Color.rgb(203, 203, 203));
    
    ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
    sets.add(d);
    
    BarData cd = new BarData(getMonths(), sets);
    return cd;
}
 
Example #22
Source File: BarHighlighter.java    From iMoney with Apache License 2.0 6 votes vote down vote up
@Override
public Highlight getHighlight(float x, float y) {

	Highlight h = super.getHighlight(x, y);

	if (h == null)
		return h;
	else {

		BarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());

		if (set.isStacked()) {

			// create an array of the touch-point
			float[] pts = new float[2];
			pts[1] = y;

			// take any transformer to determine the x-axis value
			mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);

			return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[1]);
		} else
			return h;
	}
}
 
Example #23
Source File: SimpleFragment.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
protected BarData generateBarData(int dataSets, float range, int count) {
        
        ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
        
        for(int i = 0; i < dataSets; i++) {
           
            ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
            
//            entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
            
            for(int j = 0; j < count; j++) {        
                entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
            }
            
            BarDataSet ds = new BarDataSet(entries, getLabel(i));
            ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
            sets.add(ds);
        }
        
        BarData d = new BarData(ChartData.generateXVals(0, count), sets);
        d.setValueTypeface(tf);
        return d;
    }
 
Example #24
Source File: HorizontalBarHighlighter.java    From iMoney with Apache License 2.0 6 votes vote down vote up
@Override
public Highlight getHighlight(float x, float y) {

	Highlight h = super.getHighlight(x, y);

	if (h == null)
		return h;
	else {

		BarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex());

		if (set.isStacked()) {

			// create an array of the touch-point
			float[] pts = new float[2];
			pts[0] = y;

			// take any transformer to determine the x-axis value
			mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);

			return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[0]);
		} else
			return h;
	}
}
 
Example #25
Source File: BarChartActivity.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * 生成柱状图的数据
 */
private BarData generateDataBar() {

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

    for (int i = 0; i < 12; i++) {
        entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
    }

    BarDataSet d = new BarDataSet(entries, "New DataSet ");
    // 设置柱状图之间的间距
    d.setBarSpacePercent(20f);
    // 设置显示的柱状图的颜色
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    // 设置高亮的透明度:当点击柱状图时显示的透明度
    d.setHighLightAlpha(255);

    BarData cd = new BarData(getMonths(), d);
    return cd;
}
 
Example #26
Source File: BarChartActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
private void setData(int count, float range) {

        ArrayList<String> xVals = new ArrayList<String>();
        for (int i = 0; i < count; i++) {
            xVals.add(mMonths[i % 12]);
        }

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

        for (int i = 0; i < count; i++) {
            float mult = (range + 1);
            float val = (float) (Math.random() * mult);
            yVals1.add(new BarEntry(val, i));
        }

        BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
        set1.setBarSpacePercent(35f);

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

        BarData data = new BarData(xVals, dataSets);
        data.setValueTextSize(10f);
        data.setValueTypeface(mTf);

        mChart.setData(data);
    }
 
Example #27
Source File: KlineFragment.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * date: 2019/2/22
 * author: chenli
 * description: 生成成交量数据集
 */
private BarDataSet generateBarDataSet(List<BarEntry> entries, String label, boolean isHighlight, int... colors) {
    BarDataSet set = new BarDataSet(entries, label);
    set.setColors(colors);
    set.setBarBorderWidth(0);
    set.setDrawValues(false);
    set.setAxisDependency(YAxis.AxisDependency.LEFT);
    if (isHighlight) {
        set.setHighLightColor(mHighlightColor);
    } else {
        set.setHighlightEnabled(false);
    }
    return set;
}
 
Example #28
Source File: ExpenseDetailFragment.java    From Expense-Tracker-App with MIT License 5 votes vote down vote up
private void setWeekChart() {
    List<Date> dateList = DateUtils.getWeekDates();
    List<String> days = new ArrayList<>();
    Collections.sort(dateList);

    List<BarEntry> entriesPerDay = new ArrayList<>();

    for (int i=0; i < dateList.size(); i++) {
        Date date = dateList.get(i);
        String day = Util.formatDateToString(date, "EEE");
        float value = Expense.getCategoryTotalByDate(date, expense.getCategory());
        days.add(day);
        entriesPerDay.add(new BarEntry(value, i));
    }
    BarDataSet dataSet = new BarDataSet(entriesPerDay, getString(R.string.this_week));
    dataSet.setColors(Util.getListColors());
    BarData barData = new BarData(days, dataSet);
    bcWeekExpenses.setVisibleXRangeMaximum(5);
    bcWeekExpenses.getAxisLeft().setDrawGridLines(false);
    bcWeekExpenses.getXAxis().setDrawGridLines(false);
    bcWeekExpenses.getAxisRight().setDrawGridLines(false);
    bcWeekExpenses.getAxisRight().setDrawLabels(false);
    bcWeekExpenses.setData(barData);
    bcWeekExpenses.setDescription("");
    bcWeekExpenses.animateY(2000);
    bcWeekExpenses.invalidate();
}
 
Example #29
Source File: AnotherBarActivity.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    tvX.setText("" + (mSeekBarX.getProgress() + 1));
    tvY.setText("" + (mSeekBarY.getProgress()));

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

    for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
        float mult = (mSeekBarY.getProgress() + 1);
        float val1 = (float) (Math.random() * mult) + mult / 3;
        yVals1.add(new BarEntry((int) val1, i));
    }

    ArrayList<String> xVals = new ArrayList<String>();
    for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
        xVals.add((int) yVals1.get(i).getVal() + "");
    }

    BarDataSet set1 = new BarDataSet(yVals1, "Data Set");
    set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
    set1.setDrawValues(false);

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

    BarData data = new BarData(xVals, dataSets);

    mChart.setData(data);
    mChart.invalidate();
}
 
Example #30
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();
    }