com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet Java Examples
The following examples show how to use
com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet.
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: BubbleChart.java From Stayfit with Apache License 2.0 | 6 votes |
@Override protected void calcMinMax() { super.calcMinMax(); if (mDeltaX == 0 && mData.getYValCount() > 0) mDeltaX = 1; mXChartMin = -0.5f; mXChartMax = (float) mData.getXValCount() - 0.5f; if (mRenderer != null) { for (IBubbleDataSet set : mData.getDataSets()) { final float xmin = set.getXMin(); final float xmax = set.getXMax(); if (xmin < mXChartMin) mXChartMin = xmin; if (xmax > mXChartMax) mXChartMax = xmax; } } mDeltaX = Math.abs(mXChartMax - mXChartMin); }
Example #2
Source File: RealmDatabaseActivityBubble.java From Stayfit with Apache License 2.0 | 6 votes |
private void setData() { RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class); RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<RealmDemoData>(result, "value", "xIndex", "bubbleSize"); set.setLabel("Realm BubbleDataSet"); set.setColors(ColorTemplate.COLORFUL_COLORS, 110); ArrayList<IBubbleDataSet> dataSets = new ArrayList<IBubbleDataSet>(); dataSets.add(set); // add the dataset // create a data object with the dataset list RealmBubbleData data = new RealmBubbleData(result, "xValue", dataSets); styleData(data); // set data mChart.setData(data); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }
Example #3
Source File: BubbleChart.java From NetKnight with Apache License 2.0 | 6 votes |
@Override protected void calcMinMax() { super.calcMinMax(); if (mXAxis.mAxisRange == 0 && mData.getYValCount() > 0) mXAxis.mAxisRange = 1; mXAxis.mAxisMinimum = -0.5f; mXAxis.mAxisMaximum = (float) mData.getXValCount() - 0.5f; if (mRenderer != null) { for (IBubbleDataSet set : mData.getDataSets()) { final float xmin = set.getXMin(); final float xmax = set.getXMax(); if (xmin < mXAxis.mAxisMinimum) mXAxis.mAxisMinimum = xmin; if (xmax > mXAxis.mAxisMaximum) mXAxis.mAxisMaximum = xmax; } } mXAxis.mAxisRange = Math.abs(mXAxis.mAxisMaximum - mXAxis.mAxisMinimum); }
Example #4
Source File: BubbleChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible()) drawDataSet(c, set); } }
Example #5
Source File: BubbleChartRenderer.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example #6
Source File: BubbleChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible()) { drawDataSet(c, set); } } }
Example #7
Source File: BubbleChartRenderer.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example #8
Source File: Transformer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseY, int from, int to) { final int count = (to - from + 1) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; if (valuePointsForGenerateTransformedValuesBubble.length != count) { valuePointsForGenerateTransformedValuesBubble = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesBubble; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example #9
Source File: CombinedChart.java From Stayfit with Apache License 2.0 | 5 votes |
@Override protected void calcMinMax() { super.calcMinMax(); if (getBarData() != null || getCandleData() != null || getBubbleData() != null) { mXChartMin = -0.5f; mXChartMax = mData.getXVals().size() - 0.5f; if (getBubbleData() != null) { for (IBubbleDataSet set : getBubbleData().getDataSets()) { final float xmin = set.getXMin(); final float xmax = set.getXMax(); if (xmin < mXChartMin) mXChartMin = xmin; if (xmax > mXChartMax) mXChartMax = xmax; } } } mDeltaX = Math.abs(mXChartMax - mXChartMin); if (mDeltaX == 0.f && getLineData() != null && getLineData().getYValCount() > 0) { mDeltaX = 1.f; } }
Example #10
Source File: CombinedChart.java From NetKnight with Apache License 2.0 | 5 votes |
@Override protected void calcMinMax() { super.calcMinMax(); if (getBarData() != null || getCandleData() != null || getBubbleData() != null) { mXAxis.mAxisMinimum = -0.5f; mXAxis.mAxisMaximum = mData.getXVals().size() - 0.5f; if (getBubbleData() != null) { for (IBubbleDataSet set : getBubbleData().getDataSets()) { final float xmin = set.getXMin(); final float xmax = set.getXMax(); if (xmin < mXAxis.mAxisMinimum) mXAxis.mAxisMinimum = xmin; if (xmax > mXAxis.mAxisMaximum) mXAxis.mAxisMaximum = xmax; } } } mXAxis.mAxisRange = Math.abs(mXAxis.mAxisMaximum - mXAxis.mAxisMinimum); if (mXAxis.mAxisRange == 0.f && getLineData() != null && getLineData().getYValCount() > 0) { mXAxis.mAxisRange = 1.f; } }
Example #11
Source File: BubbleChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible()) drawDataSet(c, set); } }
Example #12
Source File: BubbleChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
@Override public void drawData(Canvas c) { BubbleData bubbleData = mChart.getBubbleData(); for (IBubbleDataSet set : bubbleData.getDataSets()) { if (set.isVisible()) drawDataSet(c, set); } }
Example #13
Source File: Transformer.java From android-kline with Apache License 2.0 | 5 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseY, int from, int to) { final int count = (to - from + 1) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; if (valuePointsForGenerateTransformedValuesBubble.length != count) { valuePointsForGenerateTransformedValuesBubble = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesBubble; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example #14
Source File: Transformer.java From Ticket-Analysis with MIT License | 5 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseY, int from, int to) { final int count = (to - from + 1) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; if (valuePointsForGenerateTransformedValuesBubble.length != count) { valuePointsForGenerateTransformedValuesBubble = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesBubble; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example #15
Source File: RealmBubbleData.java From Stayfit with Apache License 2.0 | 4 votes |
public RealmBubbleData(RealmResults<? extends RealmObject> result, String xValuesField, List<IBubbleDataSet> dataSets) { super(RealmUtils.toXVals(result, xValuesField), dataSets); }
Example #16
Source File: BubbleData.java From Stayfit with Apache License 2.0 | 4 votes |
public BubbleData(List<String> xVals, IBubbleDataSet dataSet) { super(xVals, toList(dataSet)); }
Example #17
Source File: BubbleData.java From Stayfit with Apache License 2.0 | 4 votes |
private static List<IBubbleDataSet> toList(IBubbleDataSet dataSet) { List<IBubbleDataSet> sets = new ArrayList<IBubbleDataSet>(); sets.add(dataSet); return sets; }
Example #18
Source File: BubbleData.java From Stayfit with Apache License 2.0 | 4 votes |
public BubbleData(String[] xVals, IBubbleDataSet dataSet) { super(xVals, toList(dataSet)); }
Example #19
Source File: BubbleData.java From Stayfit with Apache License 2.0 | 4 votes |
public BubbleData(List<String> xVals, List<IBubbleDataSet> dataSets) { super(xVals, dataSets); }
Example #20
Source File: BubbleChartRenderer.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { BubbleData bubbleData = mChart.getBubbleData(); float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); for (Highlight indice : indices) { IBubbleDataSet dataSet = bubbleData.getDataSetByIndex(indice.getDataSetIndex()); if (dataSet == null || !dataSet.isHighlightEnabled()) continue; BubbleEntry entryFrom = dataSet.getEntryForXIndex(mMinX); BubbleEntry entryTo = dataSet.getEntryForXIndex(mMaxX); int minx = dataSet.getEntryIndex(entryFrom); int maxx = Math.min(dataSet.getEntryIndex(entryTo) + 1, dataSet.getEntryCount()); final BubbleEntry entry = (BubbleEntry) bubbleData.getEntryForHighlight(indice); if (entry == null || entry.getXIndex() != indice.getXIndex()) continue; Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); sizeBuffer[0] = 0f; sizeBuffer[2] = 1f; trans.pointValuesToPixel(sizeBuffer); // 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); pointBuffer[0] = (float) (entry.getXIndex() - minx) * phaseX + (float) minx; pointBuffer[1] = (float) (entry.getVal()) * phaseY; trans.pointValuesToPixel(pointBuffer); float shapeHalf = getShapeSize(entry.getSize(), dataSet.getMaxSize(), referenceSize) / 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; if (indice.getXIndex() < minx || indice.getXIndex() >= maxx) continue; final int originalColor = dataSet.getColor(entry.getXIndex()); Color.RGBToHSV(Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor), _hsvBuffer); _hsvBuffer[2] *= 0.5f; final int color = Color.HSVToColor(Color.alpha(originalColor), _hsvBuffer); mHighlightPaint.setColor(color); mHighlightPaint.setStrokeWidth(dataSet.getHighlightCircleWidth()); c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mHighlightPaint); } }
Example #21
Source File: Transformer.java From Stayfit with Apache License 2.0 | 4 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseX, float phaseY, int from, int to) { final int count = (int) Math.ceil(to - from) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; float[] valuePoints = new float[count]; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = (float) (e.getXIndex() - from) * phaseX + from; valuePoints[j + 1] = e.getVal() * phaseY; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example #22
Source File: BubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
public BubbleData(List<String> xVals, List<IBubbleDataSet> dataSets) { super(xVals, dataSets); }
Example #23
Source File: BubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
public BubbleData(String[] xVals, List<IBubbleDataSet> dataSets) { super(xVals, dataSets); }
Example #24
Source File: BubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
public BubbleData(List<String> xVals, IBubbleDataSet dataSet) { super(xVals, toList(dataSet)); }
Example #25
Source File: BubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
public BubbleData(String[] xVals, IBubbleDataSet dataSet) { super(xVals, toList(dataSet)); }
Example #26
Source File: BubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
private static List<IBubbleDataSet> toList(IBubbleDataSet dataSet) { List<IBubbleDataSet> sets = new ArrayList<IBubbleDataSet>(); sets.add(dataSet); return sets; }
Example #27
Source File: RealmBubbleData.java From NetKnight with Apache License 2.0 | 4 votes |
public RealmBubbleData(RealmResults<? extends RealmObject> result, String xValuesField, List<IBubbleDataSet> dataSets) { super(RealmUtils.toXVals(result, xValuesField), dataSets); }
Example #28
Source File: BubbleChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { BubbleData bubbleData = mChart.getBubbleData(); float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX())); float phaseY = mAnimator.getPhaseY(); for (Highlight high : indices) { final int minDataSetIndex = high.getDataSetIndex() == -1 ? 0 : high.getDataSetIndex(); final int maxDataSetIndex = high.getDataSetIndex() == -1 ? bubbleData.getDataSetCount() : (high.getDataSetIndex() + 1); if (maxDataSetIndex - minDataSetIndex < 1) continue; for (int dataSetIndex = minDataSetIndex; dataSetIndex < maxDataSetIndex; dataSetIndex++) { IBubbleDataSet dataSet = bubbleData.getDataSetByIndex(dataSetIndex); if (dataSet == null || !dataSet.isHighlightEnabled()) continue; final BubbleEntry entry = (BubbleEntry) bubbleData.getEntryForHighlight(high); if (entry == null || entry.getXIndex() != high.getXIndex()) continue; BubbleEntry entryFrom = dataSet.getEntryForXIndex(mMinX); BubbleEntry entryTo = dataSet.getEntryForXIndex(mMaxX); int minx = dataSet.getEntryIndex(entryFrom); int maxx = Math.min(dataSet.getEntryIndex(entryTo) + 1, dataSet.getEntryCount()); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); 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); pointBuffer[0] = (float) (entry.getXIndex() - minx) * phaseX + (float) minx; pointBuffer[1] = (float) (entry.getVal()) * 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; if (high.getXIndex() < minx || high.getXIndex() >= maxx) continue; final int originalColor = dataSet.getColor(entry.getXIndex()); Color.RGBToHSV(Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor), _hsvBuffer); _hsvBuffer[2] *= 0.5f; final int color = Color.HSVToColor(Color.alpha(originalColor), _hsvBuffer); mHighlightPaint.setColor(color); mHighlightPaint.setStrokeWidth(dataSet.getHighlightCircleWidth()); c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mHighlightPaint); } } }
Example #29
Source File: Transformer.java From NetKnight with Apache License 2.0 | 4 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseX, float phaseY, int from, int to) { final int count = (int) Math.ceil(to - from) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; float[] valuePoints = new float[count]; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = (float) (e.getXIndex() - from) * phaseX + from; valuePoints[j + 1] = e.getVal() * phaseY; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example #30
Source File: BubbleChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { BubbleData bubbleData = mChart.getBubbleData(); float phaseY = mAnimator.getPhaseY(); for (Highlight high : indices) { IBubbleDataSet set = bubbleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; final BubbleEntry entry = set.getEntryForXValue(high.getX(), high.getY()); if (entry.getY() != high.getY()) continue; if (!isInBoundsX(entry, set)) continue; Transformer trans = mChart.getTransformer(set.getAxisDependency()); sizeBuffer[0] = 0f; sizeBuffer[2] = 1f; trans.pointValuesToPixel(sizeBuffer); boolean normalizeSize = set.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); pointBuffer[0] = entry.getX(); pointBuffer[1] = (entry.getY()) * phaseY; trans.pointValuesToPixel(pointBuffer); high.setDraw(pointBuffer[0], pointBuffer[1]); float shapeHalf = getShapeSize(entry.getSize(), set.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 originalColor = set.getColor((int) entry.getX()); Color.RGBToHSV(Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor), _hsvBuffer); _hsvBuffer[2] *= 0.5f; final int color = Color.HSVToColor(Color.alpha(originalColor), _hsvBuffer); mHighlightPaint.setColor(color); mHighlightPaint.setStrokeWidth(set.getHighlightCircleWidth()); c.drawCircle(pointBuffer[0], pointBuffer[1], shapeHalf, mHighlightPaint); } }