Search in sources :

Example 1 with RadarData

use of com.github.mikephil.charting.data.RadarData in project MPAndroidChart by PhilJay.

the class RadarChartRenderer method drawHighlighted.

@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);
}
Also used : RadarEntry(com.github.mikephil.charting.data.RadarEntry) Highlight(com.github.mikephil.charting.highlight.Highlight) IRadarDataSet(com.github.mikephil.charting.interfaces.datasets.IRadarDataSet) MPPointF(com.github.mikephil.charting.utils.MPPointF) RadarData(com.github.mikephil.charting.data.RadarData) Paint(android.graphics.Paint)

Example 2 with RadarData

use of com.github.mikephil.charting.data.RadarData in project MPAndroidChart by PhilJay.

the class RadarChartActivitry method setData.

public void setData() {
    float mult = 80;
    float min = 20;
    int cnt = 5;
    ArrayList<RadarEntry> entries1 = new ArrayList<RadarEntry>();
    ArrayList<RadarEntry> entries2 = new ArrayList<RadarEntry>();
    // the chart.
    for (int i = 0; i < cnt; i++) {
        float val1 = (float) (Math.random() * mult) + min;
        entries1.add(new RadarEntry(val1));
        float val2 = (float) (Math.random() * mult) + 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<IRadarDataSet>();
    sets.add(set1);
    sets.add(set2);
    RadarData data = new RadarData(sets);
    data.setValueTypeface(mTfLight);
    data.setValueTextSize(8f);
    data.setDrawValues(false);
    data.setValueTextColor(Color.WHITE);
    mChart.setData(data);
    mChart.invalidate();
}
Also used : RadarEntry(com.github.mikephil.charting.data.RadarEntry) RadarDataSet(com.github.mikephil.charting.data.RadarDataSet) IRadarDataSet(com.github.mikephil.charting.interfaces.datasets.IRadarDataSet) IRadarDataSet(com.github.mikephil.charting.interfaces.datasets.IRadarDataSet) ArrayList(java.util.ArrayList) RadarData(com.github.mikephil.charting.data.RadarData)

Example 3 with RadarData

use of com.github.mikephil.charting.data.RadarData in project MPAndroidChart by PhilJay.

the class RealmDatabaseActivityRadar method setData.

private void setData() {
    RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
    //RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
    // stacked entries
    RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "yValue");
    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>();
    // add the dataset
    dataSets.add(set);
    // create a data object with the dataset list
    RadarData data = new RadarData(dataSets);
    styleData(data);
    // set data
    mChart.setData(data);
    mChart.animateY(1400);
}
Also used : RealmRadarDataSet(com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet) IRadarDataSet(com.github.mikephil.charting.interfaces.datasets.IRadarDataSet) ArrayList(java.util.ArrayList) RadarData(com.github.mikephil.charting.data.RadarData) RealmDemoData(com.xxmassdeveloper.mpchartexample.custom.RealmDemoData)

Example 4 with RadarData

use of com.github.mikephil.charting.data.RadarData in project MPAndroidChart by PhilJay.

the class RadarChartRenderer method drawData.

@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);
        }
    }
}
Also used : IRadarDataSet(com.github.mikephil.charting.interfaces.datasets.IRadarDataSet) RadarData(com.github.mikephil.charting.data.RadarData) Paint(android.graphics.Paint)

Aggregations

RadarData (com.github.mikephil.charting.data.RadarData)4 IRadarDataSet (com.github.mikephil.charting.interfaces.datasets.IRadarDataSet)4 Paint (android.graphics.Paint)2 RadarEntry (com.github.mikephil.charting.data.RadarEntry)2 ArrayList (java.util.ArrayList)2 RadarDataSet (com.github.mikephil.charting.data.RadarDataSet)1 RealmRadarDataSet (com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet)1 Highlight (com.github.mikephil.charting.highlight.Highlight)1 MPPointF (com.github.mikephil.charting.utils.MPPointF)1 RealmDemoData (com.xxmassdeveloper.mpchartexample.custom.RealmDemoData)1