Java Code Examples for com.github.mikephil.charting.data.BubbleDataSet#setDrawValues()

The following examples show how to use com.github.mikephil.charting.data.BubbleDataSet#setDrawValues() . 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 6 votes vote down vote up
private BubbleData generateBubbleData() {

        BubbleData bd = new BubbleData();

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

        for (int index = 0; index < count; index++) {
            float y = getRandom(10, 105);
            float size = getRandom(100, 105);
            entries.add(new BubbleEntry(index + 0.5f, y, size));
        }

        BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.WHITE);
        set.setHighlightCircleWidth(1.5f);
        set.setDrawValues(true);
        bd.addDataSet(set);

        return bd;
    }
 
Example 2
Source File: CombinedChartActivity.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
protected BubbleData generateBubbleData() {

        BubbleData bd = new BubbleData();

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

        for (int index = 0; index < itemcount; index++) {
            float rnd = getRandom(20, 30);
            entries.add(new BubbleEntry(index, rnd, rnd));
        }

        BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
        set.setColors(ColorTemplate.VORDIPLOM_COLORS);
        set.setValueTextSize(10f);
        set.setValueTextColor(Color.WHITE);
        set.setHighlightCircleWidth(1.5f);
        set.setDrawValues(true);
        bd.addDataSet(set);

        return bd;
    }
 
Example 3
Source File: BubbleChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    int count = seekBarX.getProgress();
    int range = seekBarY.getProgress();

    tvX.setText(String.valueOf(count));
    tvY.setText(String.valueOf(range));

    ArrayList<BubbleEntry> values1 = new ArrayList<>();
    ArrayList<BubbleEntry> values2 = new ArrayList<>();
    ArrayList<BubbleEntry> values3 = new ArrayList<>();

    for (int i = 0; i < count; i++) {
        values1.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
        values2.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
        values3.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range)));
    }

    // create a dataset and give it a type
    BubbleDataSet set1 = new BubbleDataSet(values1, "DS 1");
    set1.setDrawIcons(false);
    set1.setColor(ColorTemplate.COLORFUL_COLORS[0], 130);
    set1.setDrawValues(true);

    BubbleDataSet set2 = new BubbleDataSet(values2, "DS 2");
    set2.setDrawIcons(false);
    set2.setIconsOffset(new MPPointF(0, 15));
    set2.setColor(ColorTemplate.COLORFUL_COLORS[1], 130);
    set2.setDrawValues(true);

    BubbleDataSet set3 = new BubbleDataSet(values3, "DS 3");
    set3.setColor(ColorTemplate.COLORFUL_COLORS[2], 130);
    set3.setDrawValues(true);

    ArrayList<IBubbleDataSet> dataSets = new ArrayList<>();
    dataSets.add(set1); // add the data sets
    dataSets.add(set2);
    dataSets.add(set3);

    // create a data object with the data sets
    BubbleData data = new BubbleData(dataSets);
    data.setDrawValues(false);
    data.setValueTypeface(tfLight);
    data.setValueTextSize(8f);
    data.setValueTextColor(Color.WHITE);
    data.setHighlightCircleWidth(1.5f);

    chart.setData(data);
    chart.invalidate();
}