com.github.mikephil.charting.data.RadarData Java Examples

The following examples show how to use com.github.mikephil.charting.data.RadarData. 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: RealmDatabaseActivityRadar.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
private void setData() {

        RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);

        //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
        RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "value", "xIndex"); // stacked entries
        set.setLabel("Realm RadarDataSet");
        set.setDrawFilled(true);
        set.setColor(ColorTemplate.rgb("#009688"));
        set.setFillColor(ColorTemplate.rgb("#009688"));
        set.setFillAlpha(130);
        set.setLineWidth(2f);

        ArrayList<IRadarDataSet> dataSets = new ArrayList<IRadarDataSet>();
        dataSets.add(set); // add the dataset

        // create a data object with the dataset list
        RadarData data = new RadarData(new String[] {"2013", "2014", "2015", "2016", "2017", "2018", "2019"}, dataSets);
        styleData(data);

        // set data
        mChart.setData(data);
        mChart.animateY(1400);
    }
 
Example #2
Source File: RadarChartRenderer.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    RadarData radarData = mChart.getData();

    int mostEntries = radarData.getMaxEntryCountSet().getEntryCount();

    for (IRadarDataSet set : radarData.getDataSets()) {

        if (set.isVisible()) {
            drawDataSet(c, set, mostEntries);
        }
    }
}
 
Example #3
Source File: RadarChartRenderer.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    RadarData radarData = mChart.getData();

    int mostEntries = radarData.getMaxEntryCountSet().getEntryCount();

    for (IRadarDataSet set : radarData.getDataSets()) {

        if (set.isVisible()) {
            drawDataSet(c, set, mostEntries);
        }
    }
}
 
Example #4
Source File: RadarChartRenderer.java    From android-kline with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    RadarData radarData = mChart.getData();

    int mostEntries = radarData.getMaxEntryCountSet().getEntryCount();

    for (IRadarDataSet set : radarData.getDataSets()) {

        if (set.isVisible()) {
            drawDataSet(c, set, mostEntries);
        }
    }
}
 
Example #5
Source File: RadarChartRenderer.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@Override
public void drawData(Canvas c) {

    RadarData radarData = mChart.getData();

    for (RadarDataSet set : radarData.getDataSets()) {

        if (set.isVisible() && set.getEntryCount() > 0)
            drawDataSet(c, set);
    }
}
 
Example #6
Source File: RadarChartRenderer.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    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);

    RadarData radarData = mChart.getData();

    for (Highlight high : indices) {

        IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());

        if (set == null || !set.isHighlightEnabled()) {
            continue;
        }

        RadarEntry e = set.getEntryForIndex((int) high.getX());

        if (!isInBoundsX(e, set)) {
            continue;
        }

        float y = (e.getY() - mChart.getYChartMin());

        Utils.getPosition(center,
                y * factor * mAnimator.getPhaseY(),
                sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
                pOut);

        high.setDraw(pOut.x, pOut.y);

        // draw the lines
        drawHighlightLines(c, pOut.x, pOut.y, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.colorWithAlpha(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        pOut,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
Example #7
Source File: RadarChartActivity.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
private void setData() {

        float mul = 80;
        float min = 20;
        int cnt = 5;

        ArrayList<RadarEntry> entries1 = new ArrayList<>();
        ArrayList<RadarEntry> entries2 = new ArrayList<>();

        // NOTE: The order of the entries when being added to the entries array determines their position around the center of
        // the chart.
        for (int i = 0; i < cnt; i++) {
            float val1 = (float) (Math.random() * mul) + min;
            entries1.add(new RadarEntry(val1));

            float val2 = (float) (Math.random() * mul) + min;
            entries2.add(new RadarEntry(val2));
        }

        RadarDataSet set1 = new RadarDataSet(entries1, "Last Week");
        set1.setColor(Color.rgb(103, 110, 129));
        set1.setFillColor(Color.rgb(103, 110, 129));
        set1.setDrawFilled(true);
        set1.setFillAlpha(180);
        set1.setLineWidth(2f);
        set1.setDrawHighlightCircleEnabled(true);
        set1.setDrawHighlightIndicators(false);

        RadarDataSet set2 = new RadarDataSet(entries2, "This Week");
        set2.setColor(Color.rgb(121, 162, 175));
        set2.setFillColor(Color.rgb(121, 162, 175));
        set2.setDrawFilled(true);
        set2.setFillAlpha(180);
        set2.setLineWidth(2f);
        set2.setDrawHighlightCircleEnabled(true);
        set2.setDrawHighlightIndicators(false);

        ArrayList<IRadarDataSet> sets = new ArrayList<>();
        sets.add(set1);
        sets.add(set2);

        RadarData data = new RadarData(sets);
        data.setValueTypeface(tfLight);
        data.setValueTextSize(8f);
        data.setDrawValues(false);
        data.setValueTextColor(Color.WHITE);

        chart.setData(data);
        chart.invalidate();
    }
 
Example #8
Source File: RadarChartRenderer.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    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);

    RadarData radarData = mChart.getData();

    for (Highlight high : indices) {

        IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        RadarEntry e = set.getEntryForIndex((int) high.getX());

        if (!isInBoundsX(e, set))
            continue;

        float y = (e.getY() - mChart.getYChartMin());

        Utils.getPosition(center,
                y * factor * mAnimator.getPhaseY(),
                sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
                pOut);

        high.setDraw(pOut.x, pOut.y);

        // draw the lines
        drawHighlightLines(c, pOut.x, pOut.y, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.colorWithAlpha(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        pOut,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
Example #9
Source File: RadarChartRenderer.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {

    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);

    RadarData radarData = mChart.getData();

    for (Highlight high : indices) {

        IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());

        if (set == null || !set.isHighlightEnabled())
            continue;

        RadarEntry e = set.getEntryForIndex((int) high.getX());

        if (!isInBoundsX(e, set))
            continue;

        float y = (e.getY() - mChart.getYChartMin());

        Utils.getPosition(center,
                y * factor * mAnimator.getPhaseY(),
                sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
                pOut);

        high.setDraw(pOut.x, pOut.y);

        // draw the lines
        drawHighlightLines(c, pOut.x, pOut.y, set);

        if (set.isDrawHighlightCircleEnabled()) {

            if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {

                int strokeColor = set.getHighlightCircleStrokeColor();
                if (strokeColor == ColorTemplate.COLOR_NONE) {
                    strokeColor = set.getColor(0);
                }

                if (set.getHighlightCircleStrokeAlpha() < 255) {
                    strokeColor = ColorTemplate.colorWithAlpha(strokeColor, set.getHighlightCircleStrokeAlpha());
                }

                drawHighlightCircle(c,
                        pOut,
                        set.getHighlightCircleInnerRadius(),
                        set.getHighlightCircleOuterRadius(),
                        set.getHighlightCircleFillColor(),
                        strokeColor,
                        set.getHighlightCircleStrokeWidth());
            }
        }
    }

    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(pOut);
}
 
Example #10
Source File: RadarChartActivitry.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
public void setData() {

        float mult = 150;
        int cnt = 9;

        ArrayList<Entry> yVals1 = new ArrayList<Entry>();
        ArrayList<Entry> yVals2 = new ArrayList<Entry>();

        // IMPORTANT: In a PieChart, no values (Entry) should have the same
        // xIndex (even if from different DataSets), since no values can be
        // drawn above each other.
        for (int i = 0; i < cnt; i++) {
            yVals1.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
        }

        for (int i = 0; i < cnt; i++) {
            yVals2.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
        }

        ArrayList<String> xVals = new ArrayList<String>();

        for (int i = 0; i < cnt; i++)
            xVals.add(mParties[i % mParties.length]);

        RadarDataSet set1 = new RadarDataSet(yVals1, "Set 1");
        set1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        set1.setFillColor(ColorTemplate.VORDIPLOM_COLORS[0]);
        set1.setDrawFilled(true);
        set1.setLineWidth(2f);

        RadarDataSet set2 = new RadarDataSet(yVals2, "Set 2");
        set2.setColor(ColorTemplate.VORDIPLOM_COLORS[4]);
        set2.setFillColor(ColorTemplate.VORDIPLOM_COLORS[4]);
        set2.setDrawFilled(true);
        set2.setLineWidth(2f);

        ArrayList<IRadarDataSet> sets = new ArrayList<IRadarDataSet>();
        sets.add(set1);
        sets.add(set2);

        RadarData data = new RadarData(xVals, sets);
        data.setValueTypeface(tf);
        data.setValueTextSize(8f);
        data.setDrawValues(false);

        mChart.setData(data);

        mChart.invalidate();
    }
 
Example #11
Source File: RadarChartManager.java    From react-native-mp-android-chart with MIT License 4 votes vote down vote up
@Override
ChartData createData(String[] xValues) {
    return new RadarData(xValues);
}