Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IPieDataSet#getEntryCount()
The following examples show how to use
com.github.mikephil.charting.interfaces.datasets.IPieDataSet#getEntryCount() .
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: PieChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); Bitmap drawBitmap = mDrawBitmap == null ? null : mDrawBitmap.get(); if (drawBitmap == null || (drawBitmap.getWidth() != width) || (drawBitmap.getHeight() != height)) { if (width > 0 && height > 0) { drawBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444); mDrawBitmap = new WeakReference<>(drawBitmap); mBitmapCanvas = new Canvas(drawBitmap); } else { return; } } drawBitmap.eraseColor(Color.TRANSPARENT); PieData pieData = mChart.getData(); for (IPieDataSet set : pieData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) { drawDataSet(c, set); } } }
Example 2
Source File: PieChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); if (mDrawBitmap == null || (mDrawBitmap.get().getWidth() != width) || (mDrawBitmap.get().getHeight() != height)) { if (width > 0 && height > 0) { mDrawBitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444)); mBitmapCanvas = new Canvas(mDrawBitmap.get()); } else return; } mDrawBitmap.get().eraseColor(Color.TRANSPARENT); PieData pieData = mChart.getData(); for (IPieDataSet set : pieData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example 3
Source File: PieChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); if (mDrawBitmap == null || (mDrawBitmap.get().getWidth() != width) || (mDrawBitmap.get().getHeight() != height)) { if (width > 0 && height > 0) { mDrawBitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444)); mBitmapCanvas = new Canvas(mDrawBitmap.get()); } else return; } mDrawBitmap.get().eraseColor(Color.TRANSPARENT); PieData pieData = mChart.getData(); for (IPieDataSet set : pieData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example 4
Source File: PieChartRenderer.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); if (mDrawBitmap == null || (mDrawBitmap.get().getWidth() != width) || (mDrawBitmap.get().getHeight() != height)) { if (width > 0 && height > 0) { mDrawBitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444)); mBitmapCanvas = new Canvas(mDrawBitmap.get()); } else return; } mDrawBitmap.get().eraseColor(Color.TRANSPARENT); PieData pieData = mChart.getData(); for (IPieDataSet set : pieData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example 5
Source File: PieChartRenderer.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); if (mDrawBitmap == null || (mDrawBitmap.get().getWidth() != width) || (mDrawBitmap.get().getHeight() != height)) { if (width > 0 && height > 0) { mDrawBitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444)); mBitmapCanvas = new Canvas(mDrawBitmap.get()); } else return; } mDrawBitmap.get().eraseColor(Color.TRANSPARENT); PieData pieData = mChart.getData(); for (IPieDataSet set : pieData.getDataSets()) { if (set.isVisible() && set.getEntryCount() > 0) drawDataSet(c, set); } }
Example 6
Source File: PieChart.java From StockChart-MPAndroidChart with MIT License | 4 votes |
/** * calculates the needed angles for the chart slices */ private void calcAngles() { int entryCount = mData.getEntryCount(); if (mDrawAngles.length != entryCount) { mDrawAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mDrawAngles[i] = 0; } } if (mAbsoluteAngles.length != entryCount) { mAbsoluteAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mAbsoluteAngles[i] = 0; } } float yValueSum = mData.getYValueSum(); List<IPieDataSet> dataSets = mData.getDataSets(); boolean hasMinAngle = mMinAngleForSlices != 0f && entryCount * mMinAngleForSlices <= mMaxAngle; float[] minAngles = new float[entryCount]; int cnt = 0; float offset = 0f; float diff = 0f; for (int i = 0; i < mData.getDataSetCount(); i++) { IPieDataSet set = dataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { float drawAngle = calcAngle(Math.abs(set.getEntryForIndex(j).getY()), yValueSum); if (hasMinAngle) { float temp = drawAngle - mMinAngleForSlices; if (temp <= 0) { minAngles[cnt] = mMinAngleForSlices; offset += -temp; } else { minAngles[cnt] = drawAngle; diff += temp; } } mDrawAngles[cnt] = drawAngle; if (cnt == 0) { mAbsoluteAngles[cnt] = mDrawAngles[cnt]; } else { mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt]; } cnt++; } } if (hasMinAngle) { // Correct bigger slices by relatively reducing their angles based on the total angle needed to subtract // This requires that `entryCount * mMinAngleForSlices <= mMaxAngle` be true to properly work! for (int i = 0; i < entryCount; i++) { minAngles[i] -= (minAngles[i] - mMinAngleForSlices) / diff * offset; if (i == 0) { mAbsoluteAngles[0] = minAngles[0]; } else { mAbsoluteAngles[i] = mAbsoluteAngles[i - 1] + minAngles[i]; } } mDrawAngles = minAngles; } }
Example 7
Source File: PieChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
/** * This gives all pie-slices a rounded edge. * * @param c */ protected void drawRoundedSlices(Canvas c) { if (!mChart.isDrawRoundedSlicesEnabled()) { return; } IPieDataSet dataSet = mChart.getData().getDataSet(); if (!dataSet.isVisible()) { return; } float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); MPPointF center = mChart.getCenterCircleBox(); float r = mChart.getRadius(); // calculate the radius of the "slice-circle" float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f; float[] drawAngles = mChart.getDrawAngles(); float angle = mChart.getRotationAngle(); for (int j = 0; j < dataSet.getEntryCount(); j++) { float sliceAngle = drawAngles[j]; Entry e = dataSet.getEntryForIndex(j); // draw only if the value is greater than zero if ((Math.abs(e.getY()) > Utils.FLOAT_EPSILON)) { float x = (float) ((r - circleRadius) * Math.cos(Math.toRadians((angle + sliceAngle) * phaseY)) + center.x); float y = (float) ((r - circleRadius) * Math.sin(Math.toRadians((angle + sliceAngle) * phaseY)) + center.y); mRenderPaint.setColor(dataSet.getColor(j)); mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint); } angle += sliceAngle * phaseX; } MPPointF.recycleInstance(center); }
Example 8
Source File: PieChart.java From Ticket-Analysis with MIT License | 4 votes |
/** * calculates the needed angles for the chart slices */ private void calcAngles() { int entryCount = mData.getEntryCount(); if (mDrawAngles.length != entryCount) { mDrawAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mDrawAngles[i] = 0; } } if (mAbsoluteAngles.length != entryCount) { mAbsoluteAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mAbsoluteAngles[i] = 0; } } float yValueSum = mData.getYValueSum(); List<IPieDataSet> dataSets = mData.getDataSets(); int cnt = 0; for (int i = 0; i < mData.getDataSetCount(); i++) { IPieDataSet set = dataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getY()), yValueSum); if (cnt == 0) { mAbsoluteAngles[cnt] = mDrawAngles[cnt]; } else { mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt]; } cnt++; } } }
Example 9
Source File: PieChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
/** * This gives all pie-slices a rounded edge. * * @param c */ protected void drawRoundedSlices(Canvas c) { if (!mChart.isDrawRoundedSlicesEnabled()) return; IPieDataSet dataSet = mChart.getData().getDataSet(); if (!dataSet.isVisible()) return; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); MPPointF center = mChart.getCenterCircleBox(); float r = mChart.getRadius(); // calculate the radius of the "slice-circle" float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f; float[] drawAngles = mChart.getDrawAngles(); float angle = mChart.getRotationAngle(); for (int j = 0; j < dataSet.getEntryCount(); j++) { float sliceAngle = drawAngles[j]; Entry e = dataSet.getEntryForIndex(j); // draw only if the value is greater than zero if ((Math.abs(e.getY()) > Utils.FLOAT_EPSILON)) { float x = (float) ((r - circleRadius) * Math.cos(Math.toRadians((angle + sliceAngle) * phaseY)) + center.x); float y = (float) ((r - circleRadius) * Math.sin(Math.toRadians((angle + sliceAngle) * phaseY)) + center.y); mRenderPaint.setColor(dataSet.getColor(j)); mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint); } angle += sliceAngle * phaseX; } MPPointF.recycleInstance(center); }
Example 10
Source File: PieChart.java From android-kline with Apache License 2.0 | 4 votes |
/** * calculates the needed angles for the chart slices */ private void calcAngles() { int entryCount = mData.getEntryCount(); if (mDrawAngles.length != entryCount) { mDrawAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mDrawAngles[i] = 0; } } if (mAbsoluteAngles.length != entryCount) { mAbsoluteAngles = new float[entryCount]; } else { for (int i = 0; i < entryCount; i++) { mAbsoluteAngles[i] = 0; } } float yValueSum = mData.getYValueSum(); List<IPieDataSet> dataSets = mData.getDataSets(); int cnt = 0; for (int i = 0; i < mData.getDataSetCount(); i++) { IPieDataSet set = dataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getY()), yValueSum); if (cnt == 0) { mAbsoluteAngles[cnt] = mDrawAngles[cnt]; } else { mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt]; } cnt++; } } }
Example 11
Source File: PieChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
/** * This gives all pie-slices a rounded edge. * * @param c */ protected void drawRoundedSlices(Canvas c) { if (!mChart.isDrawRoundedSlicesEnabled()) return; IPieDataSet dataSet = mChart.getData().getDataSet(); if (!dataSet.isVisible()) return; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); MPPointF center = mChart.getCenterCircleBox(); float r = mChart.getRadius(); // calculate the radius of the "slice-circle" float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f; float[] drawAngles = mChart.getDrawAngles(); float angle = mChart.getRotationAngle(); for (int j = 0; j < dataSet.getEntryCount(); j++) { float sliceAngle = drawAngles[j]; Entry e = dataSet.getEntryForIndex(j); // draw only if the value is greater than zero if ((Math.abs(e.getY()) > Utils.FLOAT_EPSILON)) { float x = (float) ((r - circleRadius) * Math.cos(Math.toRadians((angle + sliceAngle) * phaseY)) + center.x); float y = (float) ((r - circleRadius) * Math.sin(Math.toRadians((angle + sliceAngle) * phaseY)) + center.y); mRenderPaint.setColor(dataSet.getColor(j)); mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint); } angle += sliceAngle * phaseX; } MPPointF.recycleInstance(center); }
Example 12
Source File: PieChartRenderer.java From Stayfit with Apache License 2.0 | 4 votes |
/** * This gives all pie-slices a rounded edge. * * @param c */ protected void drawRoundedSlices(Canvas c) { if (!mChart.isDrawRoundedSlicesEnabled()) return; IPieDataSet dataSet = mChart.getData().getDataSet(); if (!dataSet.isVisible()) return; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); PointF center = mChart.getCenterCircleBox(); float r = mChart.getRadius(); // calculate the radius of the "slice-circle" float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f; float[] drawAngles = mChart.getDrawAngles(); float angle = mChart.getRotationAngle(); for (int j = 0; j < dataSet.getEntryCount(); j++) { float sliceAngle = drawAngles[j]; Entry e = dataSet.getEntryForIndex(j); // draw only if the value is greater than zero if ((Math.abs(e.getVal()) > 0.000001)) { float x = (float) ((r - circleRadius) * Math.cos(Math.toRadians((angle + sliceAngle) * phaseY)) + center.x); float y = (float) ((r - circleRadius) * Math.sin(Math.toRadians((angle + sliceAngle) * phaseY)) + center.y); mRenderPaint.setColor(dataSet.getColor(j)); mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint); } angle += sliceAngle * phaseX; } }
Example 13
Source File: PieChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
/** * This gives all pie-slices a rounded edge. * * @param c */ protected void drawRoundedSlices(Canvas c) { if (!mChart.isDrawRoundedSlicesEnabled()) return; IPieDataSet dataSet = mChart.getData().getDataSet(); if (!dataSet.isVisible()) return; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); PointF center = mChart.getCenterCircleBox(); float r = mChart.getRadius(); // calculate the radius of the "slice-circle" float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f; float[] drawAngles = mChart.getDrawAngles(); float angle = mChart.getRotationAngle(); for (int j = 0; j < dataSet.getEntryCount(); j++) { float sliceAngle = drawAngles[j]; Entry e = dataSet.getEntryForIndex(j); // draw only if the value is greater than zero if ((Math.abs(e.getVal()) > 0.000001)) { float x = (float) ((r - circleRadius) * Math.cos(Math.toRadians((angle + sliceAngle) * phaseY)) + center.x); float y = (float) ((r - circleRadius) * Math.sin(Math.toRadians((angle + sliceAngle) * phaseY)) + center.y); mRenderPaint.setColor(dataSet.getColor(j)); mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint); } angle += sliceAngle * phaseX; } }
Example 14
Source File: PieChart.java From Stayfit with Apache License 2.0 | 3 votes |
/** * calculates the needed angles for the chart slices */ private void calcAngles() { mDrawAngles = new float[mData.getYValCount()]; mAbsoluteAngles = new float[mData.getYValCount()]; float yValueSum = mData.getYValueSum(); List<IPieDataSet> dataSets = mData.getDataSets(); int cnt = 0; for (int i = 0; i < mData.getDataSetCount(); i++) { IPieDataSet set = dataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getVal()), yValueSum); if (cnt == 0) { mAbsoluteAngles[cnt] = mDrawAngles[cnt]; } else { mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt]; } cnt++; } } }
Example 15
Source File: PieChart.java From NetKnight with Apache License 2.0 | 3 votes |
/** * calculates the needed angles for the chart slices */ private void calcAngles() { mDrawAngles = new float[mData.getYValCount()]; mAbsoluteAngles = new float[mData.getYValCount()]; float yValueSum = mData.getYValueSum(); List<IPieDataSet> dataSets = mData.getDataSets(); int cnt = 0; for (int i = 0; i < mData.getDataSetCount(); i++) { IPieDataSet set = dataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getVal()), yValueSum); if (cnt == 0) { mAbsoluteAngles[cnt] = mDrawAngles[cnt]; } else { mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt]; } cnt++; } } }