Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IPieDataSet#getEntryForIndex()

The following examples show how to use com.github.mikephil.charting.interfaces.datasets.IPieDataSet#getEntryForIndex() . 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 4 votes vote down vote up
/**
 * 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 2
Source File: PieChartRenderer.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
/**
 * 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 3
Source File: PieChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
/**
 * 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 4
Source File: PieChartRenderer.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
/**
 * 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 5
Source File: PieChartRenderer.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
/**
 * 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 6
Source File: PieHighlighter.java    From StockChart-MPAndroidChart with MIT License 3 votes vote down vote up
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {

    IPieDataSet set = mChart.getData().getDataSet();

    final Entry entry = set.getEntryForIndex(index);

    return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency());
}
 
Example 7
Source File: PieHighlighter.java    From Ticket-Analysis with MIT License 3 votes vote down vote up
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {

    IPieDataSet set = mChart.getData().getDataSet();

    final Entry entry = set.getEntryForIndex(index);

    return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency());
}
 
Example 8
Source File: PieHighlighter.java    From android-kline with Apache License 2.0 3 votes vote down vote up
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {

    IPieDataSet set = mChart.getData().getDataSet();

    final Entry entry = set.getEntryForIndex(index);

    return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency());
}