Java Code Examples for com.github.mikephil.charting.data.Entry#getY()
The following examples show how to use
com.github.mikephil.charting.data.Entry#getY() .
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: HorizontalBarChart.java From StockChart-MPAndroidChart with MIT License | 6 votes |
/** * Returns a recyclable MPPointF instance. * * @param e * @param axis * @return */ @Override public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) { return null; } float[] vals = mGetPositionBuffer; vals[0] = e.getY(); vals[1] = e.getX(); getTransformer(axis).pointValuesToPixel(vals); return MPPointF.getInstance(vals[0], vals[1]); }
Example 2
Source File: PFAMarkerView.java From privacy-friendly-shopping-list with Apache License 2.0 | 6 votes |
@Override public void refreshContent(Entry e, Highlight highlight) { float value = e.getY(); String numberSuffix = StringUtils.EMPTY; if ( numberScale != null && value > numberScale.getValue(context) ) { value /= numberScale.getValue(context); numberSuffix = numberScale.getAbbreviation(context) + StringUtils.SPACE; } String markupText = xValueFormatter.getFormattedValue(e.getX(), null) + SEPARATION + format.format(value) + SPACE + numberSuffix + unit; markup.setText(markupText); }
Example 3
Source File: HorizontalBarChart.java From android-kline with Apache License 2.0 | 5 votes |
/** * Returns a recyclable MPPointF instance. * * @param e * @param axis * @return */ @Override public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) return null; float[] vals = mGetPositionBuffer; vals[0] = e.getY(); vals[1] = e.getX(); getTransformer(axis).pointValuesToPixel(vals); return MPPointF.getInstance(vals[0], vals[1]); }
Example 4
Source File: Transformer.java From Ticket-Analysis with MIT License | 5 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the BUBBLECHART. * * @param data * @return */ public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseY, int from, int to) { final int count = (to - from + 1) * 2; // (int) Math.ceil((to - from) * phaseX) * 2; if (valuePointsForGenerateTransformedValuesBubble.length != count) { valuePointsForGenerateTransformedValuesBubble = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesBubble; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example 5
Source File: Transformer.java From android-kline with Apache License 2.0 | 5 votes |
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example 6
Source File: HorizontalBarChart.java From Ticket-Analysis with MIT License | 5 votes |
/** * Returns a recyclable MPPointF instance. * * @param e * @param axis * @return */ @Override public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) return null; float[] vals = mGetPositionBuffer; vals[0] = e.getY(); vals[1] = e.getX(); getTransformer(axis).pointValuesToPixel(vals); return MPPointF.getInstance(vals[0], vals[1]); }
Example 7
Source File: BarLineChartBase.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * Returns a recyclable MPPointF instance. * Returns the position (in pixels) the provided Entry has inside the chart * view or null, if the provided Entry is null. * * @param e * @return */ public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) { return null; } mGetPositionBuffer[0] = e.getX(); mGetPositionBuffer[1] = e.getY(); getTransformer(axis).pointValuesToPixel(mGetPositionBuffer); return MPPointF.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]); }
Example 8
Source File: AppLineChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawLastPointCircle(Canvas c) { mRenderPaint.setStyle(Paint.Style.FILL); float phaseY = mAnimator.getPhaseY(); mCirclesBuffer[0] = 0; mCirclesBuffer[1] = 0; List<ILineDataSet> dataSets = mChart.getLineData().getDataSets(); for (int i = 0; i < dataSets.size(); i++) { ILineDataSet dataSet = dataSets.get(i); if (!dataSet.isVisible() /*|| !dataSet.isDrawCirclesEnabled()*/ || dataSet.getEntryCount() == 0) continue; mRenderPaint.setColor(dataSet.getCircleColor(0)); mCirclePaintInner.setColor(dataSet.getCircleHoleColor()); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float circleRadius = dataSet.getCircleRadius() * 2.0f; float circleHoleRadius = dataSet.getCircleHoleRadius() * 2.0f; boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() && circleHoleRadius < circleRadius && circleHoleRadius > 0.f; Entry e = dataSet.getEntryForIndex(dataSet.getEntryCount() - 1); if (e == null) return; mCirclesBuffer[0] = e.getX(); mCirclesBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mCirclesBuffer); if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0])) return; if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) || !mViewPortHandler.isInBoundsY(mCirclesBuffer[1])) return; c.drawCircle( mCirclesBuffer[0], mCirclesBuffer[1], circleRadius, mRenderPaint); if (drawCircleHole) { c.drawCircle( mCirclesBuffer[0], mCirclesBuffer[1], circleHoleRadius, mCirclePaintInner); } } }
Example 9
Source File: LineChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawCubicBezier(ILineDataSet dataSet) { float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX())); float phaseY = mAnimator.getPhaseY(); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float intensity = dataSet.getCubicIntensity(); cubicPath.reset(); if (mXBounds.range >= 1) { float prevDx = 0f; float prevDy = 0f; float curDx = 0f; float curDy = 0f; // Take an extra point from the left, and an extra from the right. // That's because we need 4 points for a cubic bezier (cubic=4), otherwise we get lines moving and doing weird stuff on the edges of the chart. // So in the starting `prev` and `cur`, go -2, -1 // And in the `lastIndex`, add +1 final int firstIndex = mXBounds.min + 1; final int lastIndex = mXBounds.min + mXBounds.range; Entry prevPrev; Entry prev = dataSet.getEntryForIndex(Math.max(firstIndex - 2, 0)); Entry cur = dataSet.getEntryForIndex(Math.max(firstIndex - 1, 0)); Entry next = cur; int nextIndex = -1; if (cur == null) return; // let the spline start cubicPath.moveTo(cur.getX(), cur.getY() * phaseY); for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) { prevPrev = prev; prev = cur; cur = nextIndex == j ? next : dataSet.getEntryForIndex(j); nextIndex = j + 1 < dataSet.getEntryCount() ? j + 1 : j; next = dataSet.getEntryForIndex(nextIndex); prevDx = (cur.getX() - prevPrev.getX()) * intensity; prevDy = (cur.getY() - prevPrev.getY()) * intensity; curDx = (next.getX() - prev.getX()) * intensity; curDy = (next.getY() - prev.getY()) * intensity; cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY, cur.getX() - curDx, (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY); } } // if filled is enabled, close the path if (dataSet.isDrawFilledEnabled()) { cubicFillPath.reset(); cubicFillPath.addPath(cubicPath); drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds); } mRenderPaint.setColor(dataSet.getColor()); mRenderPaint.setStyle(Paint.Style.STROKE); trans.pathValueToPixel(cubicPath); mBitmapCanvas.drawPath(cubicPath, mRenderPaint); mRenderPaint.setPathEffect(null); }
Example 10
Source File: LineChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawCircles(Canvas c) { mRenderPaint.setStyle(Paint.Style.FILL); float phaseY = mAnimator.getPhaseY(); mCirclesBuffer[0] = 0; mCirclesBuffer[1] = 0; List<ILineDataSet> dataSets = mChart.getLineData().getDataSets(); for (int i = 0; i < dataSets.size(); i++) { ILineDataSet dataSet = dataSets.get(i); if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() || dataSet.getEntryCount() == 0) continue; mCirclePaintInner.setColor(dataSet.getCircleHoleColor()); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float circleRadius = dataSet.getCircleRadius(); float circleHoleRadius = dataSet.getCircleHoleRadius(); boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() && circleHoleRadius < circleRadius && circleHoleRadius > 0.f; boolean drawTransparentCircleHole = drawCircleHole && dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE; DataSetImageCache imageCache; if (mImageCaches.containsKey(dataSet)) { imageCache = mImageCaches.get(dataSet); } else { imageCache = new DataSetImageCache(); mImageCaches.put(dataSet, imageCache); } boolean changeRequired = imageCache.init(dataSet); // only fill the cache with new bitmaps if a change is required if (changeRequired) { imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole); } int boundsRangeCount = mXBounds.range + mXBounds.min; for (int j = mXBounds.min; j <= boundsRangeCount; j++) { Entry e = dataSet.getEntryForIndex(j); if (e == null) break; mCirclesBuffer[0] = e.getX(); mCirclesBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mCirclesBuffer); if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0])) break; if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) || !mViewPortHandler.isInBoundsY(mCirclesBuffer[1])) continue; Bitmap circleBitmap = imageCache.getBitmap(j); if (circleBitmap != null) { c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, null); } } } }
Example 11
Source File: ScatterChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) { ViewPortHandler viewPortHandler = mViewPortHandler; Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseY = mAnimator.getPhaseY(); IShapeRenderer renderer = dataSet.getShapeRenderer(); if (renderer == null) { Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet"); return; } int max = (int)(Math.min( Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()), (float)dataSet.getEntryCount())); for (int i = 0; i < max; i++) { Entry e = dataSet.getEntryForIndex(i); mPixelBuffer[0] = e.getX(); mPixelBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mPixelBuffer); if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0])) break; if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0]) || !viewPortHandler.isInBoundsY(mPixelBuffer[1])) continue; mRenderPaint.setColor(dataSet.getColor(i / 2)); renderer.renderShape( c, dataSet, mViewPortHandler, mPixelBuffer[0], mPixelBuffer[1], mRenderPaint); } }
Example 12
Source File: LineChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
protected void drawCircles(Canvas c) { mRenderPaint.setStyle(Paint.Style.FILL); float phaseY = mAnimator.getPhaseY(); mCirclesBuffer[0] = 0; mCirclesBuffer[1] = 0; List<ILineDataSet> dataSets = mChart.getLineData().getDataSets(); for (int i = 0; i < dataSets.size(); i++) { ILineDataSet dataSet = dataSets.get(i); if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() || dataSet.getEntryCount() == 0) continue; mCirclePaintInner.setColor(dataSet.getCircleHoleColor()); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float circleRadius = dataSet.getCircleRadius(); float circleHoleRadius = dataSet.getCircleHoleRadius(); boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() && circleHoleRadius < circleRadius && circleHoleRadius > 0.f; boolean drawTransparentCircleHole = drawCircleHole && dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE; DataSetImageCache imageCache; if (mImageCaches.containsKey(dataSet)) { imageCache = mImageCaches.get(dataSet); } else { imageCache = new DataSetImageCache(); mImageCaches.put(dataSet, imageCache); } boolean changeRequired = imageCache.init(dataSet); // only fill the cache with new bitmaps if a change is required if (changeRequired) { imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole); } int boundsRangeCount = mXBounds.range + mXBounds.min; for (int j = mXBounds.min; j <= boundsRangeCount; j++) { Entry e = dataSet.getEntryForIndex(j); if (e == null) break; mCirclesBuffer[0] = e.getX(); mCirclesBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mCirclesBuffer); if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0])) break; if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) || !mViewPortHandler.isInBoundsY(mCirclesBuffer[1])) continue; Bitmap circleBitmap = imageCache.getBitmap(j); if (circleBitmap != null) { c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, null); } } } }
Example 13
Source File: ScatterChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) { ViewPortHandler viewPortHandler = mViewPortHandler; Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseY = mAnimator.getPhaseY(); IShapeRenderer renderer = dataSet.getShapeRenderer(); if (renderer == null) { Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet"); return; } int max = (int)(Math.min( Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()), (float)dataSet.getEntryCount())); for (int i = 0; i < max; i++) { Entry e = dataSet.getEntryForIndex(i); mPixelBuffer[0] = e.getX(); mPixelBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mPixelBuffer); if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0])) break; if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0]) || !viewPortHandler.isInBoundsY(mPixelBuffer[1])) continue; mRenderPaint.setColor(dataSet.getColor(i / 2)); renderer.renderShape( c, dataSet, mViewPortHandler, mPixelBuffer[0], mPixelBuffer[1], mRenderPaint); } }
Example 14
Source File: LineChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawCircles(Canvas c) { mRenderPaint.setStyle(Paint.Style.FILL); float phaseY = mAnimator.getPhaseY(); mCirclesBuffer[0] = 0; mCirclesBuffer[1] = 0; List<ILineDataSet> dataSets = mChart.getLineData().getDataSets(); for (int i = 0; i < dataSets.size(); i++) { ILineDataSet dataSet = dataSets.get(i); if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() || dataSet.getEntryCount() == 0) continue; mCirclePaintInner.setColor(dataSet.getCircleHoleColor()); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float circleRadius = dataSet.getCircleRadius(); float circleHoleRadius = dataSet.getCircleHoleRadius(); boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() && circleHoleRadius < circleRadius && circleHoleRadius > 0.f; boolean drawTransparentCircleHole = drawCircleHole && dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE; DataSetImageCache imageCache; if (mImageCaches.containsKey(dataSet)) { imageCache = mImageCaches.get(dataSet); } else { imageCache = new DataSetImageCache(); mImageCaches.put(dataSet, imageCache); } boolean changeRequired = imageCache.init(dataSet); // only fill the cache with new bitmaps if a change is required if (changeRequired) { imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole); } int boundsRangeCount = mXBounds.range + mXBounds.min; for (int j = mXBounds.min; j <= boundsRangeCount; j++) { Entry e = dataSet.getEntryForIndex(j); if (e == null) break; mCirclesBuffer[0] = e.getX(); mCirclesBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mCirclesBuffer); if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0])) break; if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) || !mViewPortHandler.isInBoundsY(mCirclesBuffer[1])) continue; Bitmap circleBitmap = imageCache.getBitmap(j); if (circleBitmap != null) { c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, null); } } } }
Example 15
Source File: LineChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
protected void drawCubicBezier(ILineDataSet dataSet) { float phaseY = mAnimator.getPhaseY(); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float intensity = dataSet.getCubicIntensity(); cubicPath.reset(); if (mXBounds.range >= 1) { float prevDx = 0f; float prevDy = 0f; float curDx = 0f; float curDy = 0f; // Take an extra point from the left, and an extra from the right. // That's because we need 4 points for a cubic bezier (cubic=4), otherwise we get lines moving and doing weird stuff on the edges of the chart. // So in the starting `prev` and `cur`, go -2, -1 // And in the `lastIndex`, add +1 final int firstIndex = mXBounds.min + 1; final int lastIndex = mXBounds.min + mXBounds.range; Entry prevPrev; Entry prev = dataSet.getEntryForIndex(Math.max(firstIndex - 2, 0)); Entry cur = dataSet.getEntryForIndex(Math.max(firstIndex - 1, 0)); Entry next = cur; int nextIndex = -1; if (cur == null) { return; } // let the spline start cubicPath.moveTo(cur.getX(), cur.getY() * phaseY); for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) { prevPrev = prev; prev = cur; cur = nextIndex == j ? next : dataSet.getEntryForIndex(j); nextIndex = j + 1 < dataSet.getEntryCount() ? j + 1 : j; next = dataSet.getEntryForIndex(nextIndex); prevDx = (cur.getX() - prevPrev.getX()) * intensity; prevDy = (cur.getY() - prevPrev.getY()) * intensity; curDx = (next.getX() - prev.getX()) * intensity; curDy = (next.getY() - prev.getY()) * intensity; cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY, cur.getX() - curDx, (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY); } } // if filled is enabled, close the path if (dataSet.isDrawFilledEnabled()) { cubicFillPath.reset(); cubicFillPath.addPath(cubicPath); drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds); } mRenderPaint.setColor(dataSet.getColor()); mRenderPaint.setStyle(Paint.Style.STROKE); trans.pathValueToPixel(cubicPath); mBitmapCanvas.drawPath(cubicPath, mRenderPaint); mRenderPaint.setPathEffect(null); }
Example 16
Source File: ScatterChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) { ViewPortHandler viewPortHandler = mViewPortHandler; Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseY = mAnimator.getPhaseY(); IShapeRenderer renderer = dataSet.getShapeRenderer(); if (renderer == null) { Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet"); return; } int max = (int)(Math.min( Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()), (float)dataSet.getEntryCount())); for (int i = 0; i < max; i++) { Entry e = dataSet.getEntryForIndex(i); mPixelBuffer[0] = e.getX(); mPixelBuffer[1] = e.getY() * phaseY; trans.pointValuesToPixel(mPixelBuffer); if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0])) break; if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0]) || !viewPortHandler.isInBoundsY(mPixelBuffer[1])) continue; mRenderPaint.setColor(dataSet.getColor(i / 2)); renderer.renderShape( c, dataSet, mViewPortHandler, mPixelBuffer[0], mPixelBuffer[1], mRenderPaint); } }
Example 17
Source File: BarLineChartBase.java From android-kline with Apache License 2.0 | 3 votes |
/** * Returns a recyclable MPPointF instance. * Returns the position (in pixels) the provided Entry has inside the chart * view or null, if the provided Entry is null. * * @param e * @return */ public MPPointF getPosition(Entry e, AxisDependency axis) { if (e == null) return null; mGetPositionBuffer[0] = e.getX(); mGetPositionBuffer[1] = e.getY(); getTransformer(axis).pointValuesToPixel(mGetPositionBuffer); return MPPointF.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]); }
Example 18
Source File: PieHighlighter.java From StockChart-MPAndroidChart with MIT License | 3 votes |
@Override protected Highlight getClosestHighlight(int index, float x, float y) { IPieDataSet set = mChart.getData().getDataSet(); final Entry entry = set.getEntryForIndex(index); return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency()); }
Example 19
Source File: PieHighlighter.java From android-kline with Apache License 2.0 | 3 votes |
@Override protected Highlight getClosestHighlight(int index, float x, float y) { IPieDataSet set = mChart.getData().getDataSet(); final Entry entry = set.getEntryForIndex(index); return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency()); }
Example 20
Source File: RadarHighlighter.java From Ticket-Analysis 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; }