Java Code Examples for com.github.mikephil.charting.data.RadarEntry#getIcon()

The following examples show how to use com.github.mikephil.charting.data.RadarEntry#getIcon() . 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: RadarChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void drawValues(Canvas c) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0, 0);
    MPPointF pIcon = MPPointF.getInstance(0, 0);

    float yoffset = Utils.convertDpToPixel(5f);

    for (int i = 0; i < mChart.getData().getDataSetCount(); i++) {

        IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i);

        if (!shouldDrawValues(dataSet)) {
            continue;
        }

        // apply the text-styling defined by the DataSet
        applyValueTextStyle(dataSet);

        ValueFormatter formatter = dataSet.getValueFormatter();

        MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset());
        iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x);
        iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y);

        for (int j = 0; j < dataSet.getEntryCount(); j++) {

            RadarEntry entry = dataSet.getEntryForIndex(j);

            Utils.getPosition(
                    center,
                    (entry.getY() - mChart.getYChartMin()) * factor * phaseY,
                    sliceangle * j * phaseX + mChart.getRotationAngle(),
                    pOut);

            if (dataSet.isDrawValuesEnabled()) {
                drawValue(c, formatter.getRadarLabel(entry), pOut.x, pOut.y - yoffset, dataSet.getValueTextColor(j));
            }

            if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {

                Drawable icon = entry.getIcon();

                Utils.getPosition(
                        center,
                        (entry.getY()) * factor * phaseY + iconsOffset.y,
                        sliceangle * j * phaseX + mChart.getRotationAngle(),
                        pIcon);

                //noinspection SuspiciousNameCombination
                pIcon.y += iconsOffset.x;

                Utils.drawImage(
                        c,
                        icon,
                        (int) pIcon.x,
                        (int) pIcon.y,
                        icon.getIntrinsicWidth(),
                        icon.getIntrinsicHeight());
            }
        }

        MPPointF.recycleInstance(iconsOffset);
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
    MPPointF.recycleInstance(pIcon);
}
 
Example 2
Source File: RadarChartRenderer.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public void drawValues(Canvas c) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    MPPointF pIcon = MPPointF.getInstance(0,0);

    float yoffset = Utils.convertDpToPixel(5f);

    for (int i = 0; i < mChart.getData().getDataSetCount(); i++) {

        IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i);

        if (!shouldDrawValues(dataSet))
            continue;

        // apply the text-styling defined by the DataSet
        applyValueTextStyle(dataSet);

        MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset());
        iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x);
        iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y);

        for (int j = 0; j < dataSet.getEntryCount(); j++) {

            RadarEntry entry = dataSet.getEntryForIndex(j);

             Utils.getPosition(
                     center,
                     (entry.getY() - mChart.getYChartMin()) * factor * phaseY,
                     sliceangle * j * phaseX + mChart.getRotationAngle(),
                     pOut);

            if (dataSet.isDrawValuesEnabled()) {
                drawValue(c,
                        dataSet.getValueFormatter(),
                        entry.getY(),
                        entry,
                        i,
                        pOut.x,
                        pOut.y - yoffset,
                        dataSet.getValueTextColor
                                (j));
            }

            if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {

                Drawable icon = entry.getIcon();

                Utils.getPosition(
                        center,
                        (entry.getY()) * factor * phaseY + iconsOffset.y,
                        sliceangle * j * phaseX + mChart.getRotationAngle(),
                        pIcon);

                //noinspection SuspiciousNameCombination
                pIcon.y += iconsOffset.x;

                Utils.drawImage(
                        c,
                        icon,
                        (int)pIcon.x,
                        (int)pIcon.y,
                        icon.getIntrinsicWidth(),
                        icon.getIntrinsicHeight());
            }
        }

        MPPointF.recycleInstance(iconsOffset);
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
    MPPointF.recycleInstance(pIcon);
}
 
Example 3
Source File: RadarChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@Override
public void drawValues(Canvas c) {

    float phaseX = mAnimator.getPhaseX();
    float phaseY = mAnimator.getPhaseY();

    float sliceangle = mChart.getSliceAngle();

    // calculate the factor that is needed for transforming the value to
    // pixels
    float factor = mChart.getFactor();

    MPPointF center = mChart.getCenterOffsets();
    MPPointF pOut = MPPointF.getInstance(0,0);
    MPPointF pIcon = MPPointF.getInstance(0,0);

    float yoffset = Utils.convertDpToPixel(5f);

    for (int i = 0; i < mChart.getData().getDataSetCount(); i++) {

        IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i);

        if (!shouldDrawValues(dataSet))
            continue;

        // apply the text-styling defined by the DataSet
        applyValueTextStyle(dataSet);

        MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset());
        iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x);
        iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y);

        for (int j = 0; j < dataSet.getEntryCount(); j++) {

            RadarEntry entry = dataSet.getEntryForIndex(j);

             Utils.getPosition(
                     center,
                     (entry.getY() - mChart.getYChartMin()) * factor * phaseY,
                     sliceangle * j * phaseX + mChart.getRotationAngle(),
                     pOut);

            if (dataSet.isDrawValuesEnabled()) {
                drawValue(c,
                        dataSet.getValueFormatter(),
                        entry.getY(),
                        entry,
                        i,
                        pOut.x,
                        pOut.y - yoffset,
                        dataSet.getValueTextColor
                                (j));
            }

            if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {

                Drawable icon = entry.getIcon();

                Utils.getPosition(
                        center,
                        (entry.getY()) * factor * phaseY + iconsOffset.y,
                        sliceangle * j * phaseX + mChart.getRotationAngle(),
                        pIcon);

                //noinspection SuspiciousNameCombination
                pIcon.y += iconsOffset.x;

                Utils.drawImage(
                        c,
                        icon,
                        (int)pIcon.x,
                        (int)pIcon.y,
                        icon.getIntrinsicWidth(),
                        icon.getIntrinsicHeight());
            }
        }

        MPPointF.recycleInstance(iconsOffset);
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
    MPPointF.recycleInstance(pIcon);
}