com.github.mikephil.charting.data.RadarDataSet Java Examples
The following examples show how to use
com.github.mikephil.charting.data.RadarDataSet.
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 iMoney with Apache License 2.0 | 5 votes |
@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 #2
Source File: RadarChartManager.java From react-native-mp-android-chart with MIT License | 5 votes |
@Override void dataSetConfig(IDataSet<Entry> dataSet, ReadableMap config) { RadarDataSet radarDataSet = (RadarDataSet) dataSet; ChartDataSetConfigUtils.commonConfig(radarDataSet, config); ChartDataSetConfigUtils.commonLineScatterCandleRadarConfig(radarDataSet, config); ChartDataSetConfigUtils.commonLineRadarConfig(radarDataSet, config); // RadarDataSet only config }
Example #3
Source File: RadarChart.java From Notification-Analyser with MIT License | 5 votes |
@Override protected void drawValues() { // if values are drawn if (mDrawYValues) { float sliceangle = getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = getFactor(); PointF c = getCenterOffsets(); float yoffset = Utils.convertDpToPixel(5f); for (int i = 0; i < mCurrentData.getDataSetCount(); i++) { RadarDataSet dataSet = mCurrentData.getDataSetByIndex(i); ArrayList<Entry> entries = dataSet.getYVals(); for (int j = 0; j < entries.size(); j++) { Entry e = entries.get(j); PointF p = getPosition(c, e.getVal() * factor, sliceangle * j + mRotationAngle); if (mDrawUnitInChart) mDrawCanvas.drawText(mValueFormatter.getFormattedValue(e.getVal()) + mUnit, p.x, p.y - yoffset, mValuePaint); else mDrawCanvas.drawText(mValueFormatter.getFormattedValue(e.getVal()), p.x, p.y - yoffset, mValuePaint); } } } }
Example #4
Source File: RadarChart.java From Notification-Analyser with MIT License | 5 votes |
@Override protected void drawHighlights() { // if there are values to highlight and highlighnting is enabled, do it if (mHighlightEnabled && valuesToHighlight()) { float sliceangle = getSliceAngle(); float factor = getFactor(); PointF c = getCenterOffsets(); for (int i = 0; i < mIndicesToHightlight.length; i++) { RadarDataSet set = mCurrentData .getDataSetByIndex(mIndicesToHightlight[i] .getDataSetIndex()); if (set == null) continue; mHighlightPaint.setColor(set.getHighLightColor()); // get the index to highlight int xIndex = mIndicesToHightlight[i].getXIndex(); Entry e = set.getEntryForXIndex(xIndex); int j = set.getEntryPosition(e); float y = e.getVal(); PointF p = getPosition(c, y * factor, sliceangle * j + mRotationAngle); float[] pts = new float[] { p.x, 0, p.x, getHeight(), 0, p.y, getWidth(), p.y }; mDrawCanvas.drawLines(pts, mHighlightPaint); } } }
Example #5
Source File: RadarChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
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 #6
Source File: RadarChartRenderer.java From iMoney with Apache License 2.0 | 4 votes |
protected void drawDataSet(Canvas c, RadarDataSet dataSet) { float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); List<Entry> entries = dataSet.getYVals(); Path surface = new Path(); boolean hasMovedToPoint = false; for (int j = 0; j < entries.size(); j++) { mRenderPaint.setColor(dataSet.getColor(j)); Entry e = entries.get(j); PointF p = Utils.getPosition(center, (e.getVal() - mChart.getYChartMin()) * factor, sliceangle * j + mChart.getRotationAngle()); if (Float.isNaN(p.x)) continue; if (!hasMovedToPoint) { surface.moveTo(p.x, p.y); hasMovedToPoint = true; } else surface.lineTo(p.x, p.y); } surface.close(); // draw filled if (dataSet.isDrawFilledEnabled()) { mRenderPaint.setStyle(Paint.Style.FILL); mRenderPaint.setAlpha(dataSet.getFillAlpha()); c.drawPath(surface, mRenderPaint); mRenderPaint.setAlpha(255); } mRenderPaint.setStrokeWidth(dataSet.getLineWidth()); mRenderPaint.setStyle(Paint.Style.STROKE); // draw the line (only if filled is disabled or alpha is below 255) if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255) c.drawPath(surface, mRenderPaint); }
Example #7
Source File: RadarChartRenderer.java From iMoney with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { float sliceangle = mChart.getSliceAngle(); float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); for (int i = 0; i < indices.length; i++) { RadarDataSet set = mChart.getData() .getDataSetByIndex(indices[i] .getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; // get the index to highlight int xIndex = indices[i].getXIndex(); Entry e = set.getEntryForXIndex(xIndex); if (e == null || e.getXIndex() != xIndex) continue; int j = set.getEntryPosition(e); float y = (e.getVal() - mChart.getYChartMin()); if (Float.isNaN(y)) continue; PointF p = Utils.getPosition(center, y * factor, sliceangle * j + mChart.getRotationAngle()); float[] pts = new float[]{ p.x, p.y }; // draw the lines drawHighlightLines(c, pts, set); } }
Example #8
Source File: RadarChartActivitry.java From Stayfit with Apache License 2.0 | 4 votes |
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 #9
Source File: RadarChartManager.java From react-native-mp-android-chart with MIT License | 4 votes |
@Override IDataSet createDataSet(ArrayList<Entry> entries, String label) { return new RadarDataSet(entries, label); }
Example #10
Source File: RadarChart.java From Notification-Analyser with MIT License | 4 votes |
@Override protected void drawData() { ArrayList<RadarDataSet> dataSets = mCurrentData.getDataSets(); float sliceangle = getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = getFactor(); PointF c = getCenterOffsets(); for (int i = 0; i < mCurrentData.getDataSetCount(); i++) { RadarDataSet dataSet = dataSets.get(i); ArrayList<Entry> entries = dataSet.getYVals(); Path surface = new Path(); for (int j = 0; j < entries.size(); j++) { mRenderPaint.setColor(dataSet.getColor(j)); Entry e = entries.get(j); PointF p = getPosition(c, e.getVal() * factor, sliceangle * j + mRotationAngle); if (j == 0) surface.moveTo(p.x, p.y); else surface.lineTo(p.x, p.y); } surface.close(); // draw filled if (dataSet.isDrawFilledEnabled()) { mRenderPaint.setStyle(Paint.Style.FILL); mRenderPaint.setAlpha(dataSet.getFillAlpha()); mDrawCanvas.drawPath(surface, mRenderPaint); mRenderPaint.setAlpha(255); } mRenderPaint.setStrokeWidth(dataSet.getLineWidth()); mRenderPaint.setStyle(Paint.Style.STROKE); // draw the line (only if filled is disabled or alpha is below 255) if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255) mDrawCanvas.drawPath(surface, mRenderPaint); } }
Example #11
Source File: RadarChartRenderer.java From iMoney with Apache License 2.0 | 3 votes |
@Override public void drawValues(Canvas c) { float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); float yoffset = Utils.convertDpToPixel(5f); for (int i = 0; i < mChart.getData().getDataSetCount(); i++) { RadarDataSet dataSet = mChart.getData().getDataSetByIndex(i); if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); List<Entry> entries = dataSet.getYVals(); for (int j = 0; j < entries.size(); j++) { Entry entry = entries.get(j); PointF p = Utils.getPosition(center, (entry.getVal() - mChart.getYChartMin()) * factor, sliceangle * j + mChart.getRotationAngle()); drawValue(c, dataSet.getValueFormatter(), entry.getVal(), entry, i, p.x, p.y - yoffset); } } }