use of com.github.mikephil.charting.data.BubbleDataSet in project MPAndroidChart by PhilJay.
the class BubbleChartActivity method onProgressChanged.
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int count = mSeekBarX.getProgress();
int range = mSeekBarY.getProgress();
tvX.setText("" + count);
tvY.setText("" + range);
ArrayList<BubbleEntry> yVals1 = new ArrayList<BubbleEntry>();
ArrayList<BubbleEntry> yVals2 = new ArrayList<BubbleEntry>();
ArrayList<BubbleEntry> yVals3 = new ArrayList<BubbleEntry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range);
float size = (float) (Math.random() * range);
yVals1.add(new BubbleEntry(i, val, size, getResources().getDrawable(R.drawable.star)));
}
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range);
float size = (float) (Math.random() * range);
yVals2.add(new BubbleEntry(i, val, size, getResources().getDrawable(R.drawable.star)));
}
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range);
float size = (float) (Math.random() * range);
yVals3.add(new BubbleEntry(i, val, size));
}
// create a dataset and give it a type
BubbleDataSet set1 = new BubbleDataSet(yVals1, "DS 1");
set1.setDrawIcons(false);
set1.setColor(ColorTemplate.COLORFUL_COLORS[0], 130);
set1.setDrawValues(true);
BubbleDataSet set2 = new BubbleDataSet(yVals2, "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(yVals3, "DS 3");
set3.setColor(ColorTemplate.COLORFUL_COLORS[2], 130);
set3.setDrawValues(true);
ArrayList<IBubbleDataSet> dataSets = new ArrayList<IBubbleDataSet>();
// add the datasets
dataSets.add(set1);
dataSets.add(set2);
dataSets.add(set3);
// create a data object with the datasets
BubbleData data = new BubbleData(dataSets);
data.setDrawValues(false);
data.setValueTypeface(mTfLight);
data.setValueTextSize(8f);
data.setValueTextColor(Color.WHITE);
data.setHighlightCircleWidth(1.5f);
mChart.setData(data);
mChart.invalidate();
}
use of com.github.mikephil.charting.data.BubbleDataSet in project MPAndroidChart by PhilJay.
the class CombinedChartActivity method generateBubbleData.
protected BubbleData generateBubbleData() {
BubbleData bd = new BubbleData();
ArrayList<BubbleEntry> entries = new ArrayList<BubbleEntry>();
for (int index = 0; index < itemcount; 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;
}
Aggregations