Java Code Examples for com.github.mikephil.charting.utils.Utils#getPosition()
The following examples show how to use
com.github.mikephil.charting.utils.Utils#getPosition() .
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: XAxisRendererRadarChart.java From android-kline with Apache License 2.0 | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) return; final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f); mAxisLabelPaint.setTypeface(mXAxis.getTypeface()); mAxisLabelPaint.setTextSize(mXAxis.getTextSize()); mAxisLabelPaint.setColor(mXAxis.getTextColor()); 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); for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) { String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis); float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f; Utils.getPosition(center, mChart.getYRange() * factor + mXAxis.mLabelRotatedWidth / 2f, angle, pOut); drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f, drawLabelAnchor, labelRotationAngleDegrees); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); MPPointF.recycleInstance(drawLabelAnchor); }
Example 2
Source File: YAxisRendererRadarChart.java From android-kline with Apache License 2.0 | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) return; mAxisLabelPaint.setTypeface(mYAxis.getTypeface()); mAxisLabelPaint.setTextSize(mYAxis.getTextSize()); mAxisLabelPaint.setColor(mYAxis.getTextColor()); MPPointF center = mChart.getCenterOffsets(); MPPointF pOut = MPPointF.getInstance(0,0); float factor = mChart.getFactor(); final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1; final int to = mYAxis.isDrawTopYLabelEntryEnabled() ? mYAxis.mEntryCount : (mYAxis.mEntryCount - 1); for (int j = from; j < to; j++) { float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor; Utils.getPosition(center, r, mChart.getRotationAngle(), pOut); String label = mYAxis.getFormattedLabel(j); c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); }
Example 3
Source File: XAxisRendererRadarChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) { return; } final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f); mAxisLabelPaint.setTypeface(mXAxis.getTypeface()); mAxisLabelPaint.setTextSize(mXAxis.getTextSize()); mAxisLabelPaint.setColor(mXAxis.getTextColor()); 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); for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) { String label = mXAxis.getValueFormatter().getAxisLabel(i, mXAxis); float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f; Utils.getPosition(center, mChart.getYRange() * factor + mXAxis.mLabelRotatedWidth / 2f, angle, pOut); drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f, drawLabelAnchor, labelRotationAngleDegrees); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); MPPointF.recycleInstance(drawLabelAnchor); }
Example 4
Source File: XAxisRendererRadarChart.java From Ticket-Analysis with MIT License | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) return; final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f); mAxisLabelPaint.setTypeface(mXAxis.getTypeface()); mAxisLabelPaint.setTextSize(mXAxis.getTextSize()); mAxisLabelPaint.setColor(mXAxis.getTextColor()); 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); for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) { String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis); float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f; Utils.getPosition(center, mChart.getYRange() * factor + mXAxis.mLabelRotatedWidth / 2f, angle, pOut); drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f, drawLabelAnchor, labelRotationAngleDegrees); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); MPPointF.recycleInstance(drawLabelAnchor); }
Example 5
Source File: YAxisRendererRadarChart.java From Ticket-Analysis with MIT License | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) return; mAxisLabelPaint.setTypeface(mYAxis.getTypeface()); mAxisLabelPaint.setTextSize(mYAxis.getTextSize()); mAxisLabelPaint.setColor(mYAxis.getTextColor()); MPPointF center = mChart.getCenterOffsets(); MPPointF pOut = MPPointF.getInstance(0,0); float factor = mChart.getFactor(); final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1; final int to = mYAxis.isDrawTopYLabelEntryEnabled() ? mYAxis.mEntryCount : (mYAxis.mEntryCount - 1); for (int j = from; j < to; j++) { float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor; Utils.getPosition(center, r, mChart.getRotationAngle(), pOut); String label = mYAxis.getFormattedLabel(j); c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); }
Example 6
Source File: XAxisRendererRadarChart.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) return; final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); final PointF drawLabelAnchor = new PointF(0.5f, 0.0f); mAxisLabelPaint.setTypeface(mXAxis.getTypeface()); mAxisLabelPaint.setTextSize(mXAxis.getTextSize()); mAxisLabelPaint.setColor(mXAxis.getTextColor()); float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); int mod = mXAxis.mAxisLabelModulus; for (int i = 0; i < mXAxis.getValues().size(); i += mod) { String label = mXAxis.getValues().get(i); float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f; PointF p = Utils.getPosition(center, mChart.getYRange() * factor + mXAxis.mLabelRotatedWidth / 2f, angle); drawLabel(c, label, i, p.x, p.y - mXAxis.mLabelRotatedHeight / 2.f, drawLabelAnchor, labelRotationAngleDegrees); } }
Example 7
Source File: RadarChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
/** * Draws the RadarDataSet * * @param c * @param dataSet * @param mostEntries the entry count of the dataset with the most entries */ protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) { 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); Path surface = mDrawDataSetSurfacePathBuffer; surface.reset(); boolean hasMovedToPoint = false; for (int j = 0; j < dataSet.getEntryCount(); j++) { mRenderPaint.setColor(dataSet.getColor(j)); RadarEntry e = dataSet.getEntryForIndex(j); Utils.getPosition( center, (e.getY() - mChart.getYChartMin()) * factor * phaseY, sliceangle * j * phaseX + mChart.getRotationAngle(), pOut); if (Float.isNaN(pOut.x)) continue; if (!hasMovedToPoint) { surface.moveTo(pOut.x, pOut.y); hasMovedToPoint = true; } else surface.lineTo(pOut.x, pOut.y); } if (dataSet.getEntryCount() > mostEntries) { // if this is not the largest set, draw a line to the center before closing surface.lineTo(center.x, center.y); } surface.close(); if (dataSet.isDrawFilledEnabled()) { final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, surface, drawable); } else { drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha()); } } 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); MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); }
Example 8
Source File: RadarChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
@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 9
Source File: RadarChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
/** * Draws the RadarDataSet * * @param c * @param dataSet * @param mostEntries the entry count of the dataset with the most entries */ protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) { 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); Path surface = mDrawDataSetSurfacePathBuffer; surface.reset(); boolean hasMovedToPoint = false; for (int j = 0; j < dataSet.getEntryCount(); j++) { mRenderPaint.setColor(dataSet.getColor(j)); RadarEntry e = dataSet.getEntryForIndex(j); Utils.getPosition( center, (e.getY() - mChart.getYChartMin()) * factor * phaseY, sliceangle * j * phaseX + mChart.getRotationAngle(), pOut); if (Float.isNaN(pOut.x)) continue; if (!hasMovedToPoint) { surface.moveTo(pOut.x, pOut.y); hasMovedToPoint = true; } else surface.lineTo(pOut.x, pOut.y); } if (dataSet.getEntryCount() > mostEntries) { // if this is not the largest set, draw a line to the center before closing surface.lineTo(center.x, center.y); } surface.close(); if (dataSet.isDrawFilledEnabled()) { final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, surface, drawable); } else { drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha()); } } 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); MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); }
Example 10
Source File: RadarChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
@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 11
Source File: RadarChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
@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 12
Source File: RadarChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
protected void drawWeb(Canvas c) { float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); float rotationangle = mChart.getRotationAngle(); MPPointF center = mChart.getCenterOffsets(); // draw the web lines that come from the center mWebPaint.setStrokeWidth(mChart.getWebLineWidth()); mWebPaint.setColor(mChart.getWebColor()); mWebPaint.setAlpha(mChart.getWebAlpha()); final int xIncrements = 1 + mChart.getSkipWebLineCount(); int maxEntryCount = mChart.getData().getMaxEntryCountSet().getEntryCount(); MPPointF p = MPPointF.getInstance(0,0); for (int i = 0; i < maxEntryCount; i += xIncrements) { Utils.getPosition( center, mChart.getYRange() * factor, sliceangle * i + rotationangle, p); c.drawLine(center.x, center.y, p.x, p.y, mWebPaint); } MPPointF.recycleInstance(p); // draw the inner-web mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner()); mWebPaint.setColor(mChart.getWebColorInner()); mWebPaint.setAlpha(mChart.getWebAlpha()); int labelCount = mChart.getYAxis().mEntryCount; MPPointF p1out = MPPointF.getInstance(0,0); MPPointF p2out = MPPointF.getInstance(0,0); for (int j = 0; j < labelCount; j++) { for (int i = 0; i < mChart.getData().getEntryCount(); i++) { float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor; Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out); Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out); c.drawLine(p1out.x, p1out.y, p2out.x, p2out.y, mWebPaint); } } MPPointF.recycleInstance(p1out); MPPointF.recycleInstance(p2out); }
Example 13
Source File: RadarChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
/** * Draws the RadarDataSet * * @param c * @param dataSet * @param mostEntries the entry count of the dataset with the most entries */ protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) { 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(); PointF center = mChart.getCenterOffsets(); Path surface = new Path(); boolean hasMovedToPoint = false; for (int j = 0; j < dataSet.getEntryCount(); j++) { mRenderPaint.setColor(dataSet.getColor(j)); Entry e = dataSet.getEntryForIndex(j); PointF p = Utils.getPosition( center, (e.getVal() - mChart.getYChartMin()) * factor * phaseY, sliceangle * j * phaseX + 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); } if (dataSet.getEntryCount() > mostEntries) { // if this is not the largest set, draw a line to the center before closing surface.lineTo(center.x, center.y); } surface.close(); if(dataSet.isDrawFilledEnabled()) { final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, surface, drawable); } else { drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha()); } } 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); // // // draw filled // if (dataSet.isDrawFilledEnabled()) { // mRenderPaint.setStyle(Paint.Style.FILL); // mRenderPaint.setAlpha(dataSet.getFillAlpha()); // c.drawPath(surface, mRenderPaint); // mRenderPaint.setAlpha(255); // } }
Example 14
Source File: RadarChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
protected void drawWeb(Canvas c) { float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); float rotationangle = mChart.getRotationAngle(); PointF center = mChart.getCenterOffsets(); // draw the web lines that come from the center mWebPaint.setStrokeWidth(mChart.getWebLineWidth()); mWebPaint.setColor(mChart.getWebColor()); mWebPaint.setAlpha(mChart.getWebAlpha()); final int xIncrements = 1 + mChart.getSkipWebLineCount(); for (int i = 0; i < mChart.getData().getXValCount(); i += xIncrements) { PointF p = Utils.getPosition( center, mChart.getYRange() * factor, sliceangle * i + rotationangle); c.drawLine(center.x, center.y, p.x, p.y, mWebPaint); } // draw the inner-web mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner()); mWebPaint.setColor(mChart.getWebColorInner()); mWebPaint.setAlpha(mChart.getWebAlpha()); int labelCount = mChart.getYAxis().mEntryCount; for (int j = 0; j < labelCount; j++) { for (int i = 0; i < mChart.getData().getXValCount(); i++) { float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor; PointF p1 = Utils.getPosition(center, r, sliceangle * i + rotationangle); PointF p2 = Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle); c.drawLine(p1.x, p1.y, p2.x, p2.y, mWebPaint); } } }
Example 15
Source File: RadarChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); float sliceangle = mChart.getSliceAngle(); float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); for (int i = 0; i < indices.length; i++) { IRadarDataSet 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.getEntryIndex(e); float y = (e.getVal() - mChart.getYChartMin()); if (Float.isNaN(y)) continue; PointF p = Utils.getPosition( center, y * factor * phaseY, sliceangle * j * phaseX + mChart.getRotationAngle()); float[] pts = new float[]{ p.x, p.y }; // draw the lines drawHighlightLines(c, pts, set); if (set.isDrawHighlightCircleEnabled()) { if (!Float.isNaN(pts[0]) && !Float.isNaN(pts[1])) { int strokeColor = set.getHighlightCircleStrokeColor(); if (strokeColor == ColorTemplate.COLOR_NONE) { strokeColor = set.getColor(0); } if (set.getHighlightCircleStrokeAlpha() < 255) { strokeColor = ColorTemplate.getColorWithAlphaComponent(strokeColor, set.getHighlightCircleStrokeAlpha()); } drawHighlightCircle(c, p, set.getHighlightCircleInnerRadius(), set.getHighlightCircleOuterRadius(), set.getHighlightCircleFillColor(), strokeColor, set.getHighlightCircleStrokeWidth()); } } } }
Example 16
Source File: RadarChartRenderer.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); float sliceangle = mChart.getSliceAngle(); float factor = mChart.getFactor(); PointF center = mChart.getCenterOffsets(); for (int i = 0; i < indices.length; i++) { IRadarDataSet 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.getEntryIndex(e); float y = (e.getVal() - mChart.getYChartMin()); if (Float.isNaN(y)) continue; PointF p = Utils.getPosition( center, y * factor * phaseY, sliceangle * j * phaseX + mChart.getRotationAngle()); float[] pts = new float[]{ p.x, p.y }; // draw the lines drawHighlightLines(c, pts, set); } }
Example 17
Source File: YAxisRendererRadarChart.java From NetKnight with Apache License 2.0 | 3 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) return; mAxisLabelPaint.setTypeface(mYAxis.getTypeface()); mAxisLabelPaint.setTextSize(mYAxis.getTextSize()); mAxisLabelPaint.setColor(mYAxis.getTextColor()); PointF center = mChart.getCenterOffsets(); float factor = mChart.getFactor(); int labelCount = mYAxis.mEntryCount; for (int j = 0; j < labelCount; j++) { if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false) break; float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor; PointF p = Utils.getPosition(center, r, mChart.getRotationAngle()); String label = mYAxis.getFormattedLabel(j); c.drawText(label, p.x + 10, p.y, mAxisLabelPaint); } }
Example 18
Source File: RadarHighlighter.java From StockChart-MPAndroidChart with MIT License | 3 votes |
/** * Returns an array of Highlight objects for the given index. The Highlight * objects give information about the value at the selected index and the * DataSet it belongs to. INFORMATION: This method does calculations at * runtime. Do not over-use in performance critical situations. * * @param index * @return */ protected List<Highlight> getHighlightsAtIndex(int index) { mHighlightBuffer.clear(); float phaseX = mChart.getAnimator().getPhaseX(); float phaseY = mChart.getAnimator().getPhaseY(); float sliceangle = mChart.getSliceAngle(); float factor = mChart.getFactor(); MPPointF pOut = MPPointF.getInstance(0, 0); for (int i = 0; i < mChart.getData().getDataSetCount(); i++) { IDataSet<?> dataSet = mChart.getData().getDataSetByIndex(i); final Entry entry = dataSet.getEntryForIndex(index); float y = (entry.getY() - mChart.getYChartMin()); Utils.getPosition( mChart.getCenterOffsets(), y * factor * phaseY, sliceangle * index * phaseX + mChart.getRotationAngle(), pOut); mHighlightBuffer.add(new Highlight(index, entry.getY(), pOut.x, pOut.y, i, dataSet.getAxisDependency())); } return mHighlightBuffer; }
Example 19
Source File: YAxisRendererRadarChart.java From iMoney with Apache License 2.0 | 3 votes |
@Override public void renderAxisLabels(Canvas c) { if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled()) return; mAxisLabelPaint.setTypeface(mYAxis.getTypeface()); mAxisLabelPaint.setTextSize(mYAxis.getTextSize()); mAxisLabelPaint.setColor(mYAxis.getTextColor()); PointF center = mChart.getCenterOffsets(); float factor = mChart.getFactor(); int labelCount = mYAxis.mEntryCount; for (int j = 0; j < labelCount; j++) { if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false) break; float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor; PointF p = Utils.getPosition(center, r, mChart.getRotationAngle()); String label = mYAxis.getFormattedLabel(j); c.drawText(label, p.x + 10, p.y, mAxisLabelPaint); } }
Example 20
Source File: RadarChartRenderer.java From iMoney with Apache License 2.0 | 2 votes |
protected void drawWeb(Canvas c) { float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); float rotationangle = mChart.getRotationAngle(); PointF center = mChart.getCenterOffsets(); // draw the web lines that come from the center mWebPaint.setStrokeWidth(mChart.getWebLineWidth()); mWebPaint.setColor(mChart.getWebColor()); mWebPaint.setAlpha(mChart.getWebAlpha()); final int xIncrements = 1 + mChart.getSkipWebLineCount(); for (int i = 0; i < mChart.getData().getXValCount(); i += xIncrements) { PointF p = Utils.getPosition(center, mChart.getYRange() * factor, sliceangle * i + rotationangle); c.drawLine(center.x, center.y, p.x, p.y, mWebPaint); } // draw the inner-web mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner()); mWebPaint.setColor(mChart.getWebColorInner()); mWebPaint.setAlpha(mChart.getWebAlpha()); int labelCount = mChart.getYAxis().mEntryCount; for (int j = 0; j < labelCount; j++) { for (int i = 0; i < mChart.getData().getXValCount(); i++) { float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor; PointF p1 = Utils.getPosition(center, r, sliceangle * i + rotationangle); PointF p2 = Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle); c.drawLine(p1.x, p1.y, p2.x, p2.y, mWebPaint); } } }