public BubbleEntry copy() { BubbleEntry c = new BubbleEntry(getX(), getY(), mSize, getData()); return c; }
@Override public DataSet<BubbleEntry> copy() { List<BubbleEntry> entries = new ArrayList<BubbleEntry>(); for (int i = 0; i < mValues.size(); i++) { entries.add(mValues.get(i).copy()); } BubbleDataSet copied = new BubbleDataSet(entries, getLabel()); copy(copied); return copied; }
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)));
/** * Used to draw bubble size labels, calls {@link #getFormattedValue(float)} by default. * * @param bubbleEntry bubble being labeled, also contains X and Y values * @return formatted string label */ public String getBubbleLabel(BubbleEntry bubbleEntry) { return getFormattedValue(bubbleEntry.getSize()); }
if (entry.getY() != high.getY()) continue; final float referenceSize = Math.min(maxBubbleHeight, maxBubbleWidth); pointBuffer[0] = entry.getX(); pointBuffer[1] = (entry.getY()) * phaseY; trans.pointValuesToPixel(pointBuffer); float shapeHalf = getShapeSize(entry.getSize(), set.getMaxSize(), referenceSize, break; final int originalColor = set.getColor((int) entry.getX());
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; }
@Override protected void calcMinMax(BubbleEntry e) { super.calcMinMax(e); final float size = e.getSize(); if (size > mMaxSize) { mMaxSize = size; } }
@Override public BubbleEntry copy() { BubbleEntry c = new BubbleEntry(getXIndex(), getX(), getY(), mSize, getData()); return c; }
protected void drawDataSet(Canvas c, IBubbleDataSet dataSet) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseY = mAnimator.getPhaseY(); mXBounds.set(mChart, dataSet); sizeBuffer[0] = 0f; sizeBuffer[2] = 1f; trans.pointValuesToPixel(sizeBuffer); boolean normalizeSize = dataSet.isNormalizeSizeEnabled(); // calcualte the full width of 1 step on the x-axis final float maxBubbleWidth = Math.abs(sizeBuffer[2] - sizeBuffer[0]); final float maxBubbleHeight = Math.abs(mViewPortHandler.contentBottom() - mViewPortHandler.contentTop()); final float referenceSize = Math.min(maxBubbleHeight, maxBubbleWidth); for (int j = mXBounds.min; j <= mXBounds.range + mXBounds.min; j++) { final BubbleEntry entry = dataSet.getEntryForIndex(j); pointBuffer[0] = entry.getX(); pointBuffer[1] = (entry.getY()) * phaseY; trans.pointValuesToPixel(pointBuffer); float shapeHalf = getShapeSize(entry.getSize(), dataSet.getMaxSize(), referenceSize, normalizeSize) / 2f; if (!mViewPortHandler.isInBoundsTop(pointBuffer[1] + shapeHalf) || !mViewPortHandler.isInBoundsBottom(pointBuffer[1] - shapeHalf)) continue; if (!mViewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf)) continue; if (!mViewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf)) break; final int color = dataSet.getColor((int) entry.getX()); mRenderPaint.setColor(color); c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mRenderPaint); } }
float size = (float) (Math.random() * range); yVals1.add(new BubbleEntry(i, val, size)); float size = (float) (Math.random() * range); yVals2.add(new BubbleEntry(i, val, size)); float size = (float) (Math.random() * range); yVals3.add(new BubbleEntry(i, val, size));
@Override protected void calcMinMax(BubbleEntry e) { super.calcMinMax(e); final float size = e.getSize(); if (size > mMaxSize) { mMaxSize = size; } }
@Override public DataSet<BubbleEntry> copy() { List<BubbleEntry> yVals = new ArrayList<BubbleEntry>(); for (int i = 0; i < mValues.size(); i++) { yVals.add(mValues.get(i).copy()); } BubbleDataSet copied = new BubbleDataSet(yVals, getLabel()); copied.mColors = mColors; copied.mHighLightColor = mHighLightColor; return copied; }
public BubbleEntry copy() { BubbleEntry c = new BubbleEntry(getX(), getY(), mSize, getData()); return c; }
protected void drawDataSet(Canvas c, IBubbleDataSet dataSet) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseY = mAnimator.getPhaseY(); mXBounds.set(mChart, dataSet); sizeBuffer[0] = 0f; sizeBuffer[2] = 1f; trans.pointValuesToPixel(sizeBuffer); boolean normalizeSize = dataSet.isNormalizeSizeEnabled(); // calcualte the full width of 1 step on the x-axis final float maxBubbleWidth = Math.abs(sizeBuffer[2] - sizeBuffer[0]); final float maxBubbleHeight = Math.abs(mViewPortHandler.contentBottom() - mViewPortHandler.contentTop()); final float referenceSize = Math.min(maxBubbleHeight, maxBubbleWidth); for (int j = mXBounds.min; j <= mXBounds.range + mXBounds.min; j++) { final BubbleEntry entry = dataSet.getEntryForIndex(j); pointBuffer[0] = entry.getX(); pointBuffer[1] = (entry.getY()) * phaseY; trans.pointValuesToPixel(pointBuffer); float shapeHalf = getShapeSize(entry.getSize(), dataSet.getMaxSize(), referenceSize, normalizeSize) / 2f; if (!mViewPortHandler.isInBoundsTop(pointBuffer[1] + shapeHalf) || !mViewPortHandler.isInBoundsBottom(pointBuffer[1] - shapeHalf)) continue; if (!mViewPortHandler.isInBoundsLeft(pointBuffer[0] + shapeHalf)) continue; if (!mViewPortHandler.isInBoundsRight(pointBuffer[0] - shapeHalf)) break; final int color = dataSet.getColor((int) entry.getX()); mRenderPaint.setColor(color); c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mRenderPaint); } }