Java Code Examples for com.github.mikephil.charting.data.CandleEntry#getLow()
The following examples show how to use
com.github.mikephil.charting.data.CandleEntry#getLow() .
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: MyTransformer.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
public float[] generateTransformedValuesCandleLow(ICandleDataSet data, float phaseX, float phaseY, int from, int to) { final int count = (int) ((to - from) * phaseX + 1) * 2; if (valuePointsForGenerateTransformedValuesCandleLow.length != count) { valuePointsForGenerateTransformedValuesCandleLow = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesCandleLow; for (int j = 0; j < count; j += 2) { CandleEntry e = data.getEntryForIndex(j / 2 + from); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getLow() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Example 2
Source File: MyCandleStickChartRenderer.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXValue(high.getX(), high.getY()); if (!isInBoundsX(e, set)) continue; float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); MPPointD pix = mChart.getTransformer(set.getAxisDependency()) .getPixelForValues(e.getX(), (lowValue + highValue) / 2f); float xp = (float) pix.x; mHighlightPaint.setColor(set.getHighLightColor()); mHighlightPaint.setStrokeWidth(set.getHighlightLineWidth()); float xMax = mViewPortHandler.contentRight(); float contentBottom = mViewPortHandler.contentBottom(); //绘制竖线 c.drawLine(xp, 1, xp, mChart.getHeight(), mHighlightPaint); //判断是否画横线 float y = high.getDrawY(); if (y >= 0 && y <= contentBottom) {//在区域内即绘制横线 //绘制横线 c.drawLine(0, y, xMax, y, mHighlightPaint); } } }
Example 3
Source File: RealmCandleDataSet.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void calcMinMax(int start, int end) { if (mValues == null) return; if (mValues.size() == 0) return; int endValue; if (end == 0 || end >= mValues.size()) endValue = mValues.size() - 1; else endValue = end; mYMin = Float.MAX_VALUE; mYMax = -Float.MAX_VALUE; for (int i = start; i <= endValue; i++) { CandleEntry e = mValues.get(i); if (e.getLow() < mYMin) mYMin = e.getLow(); if (e.getHigh() > mYMax) mYMax = e.getHigh(); } }
Example 4
Source File: RealmCandleDataSet.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public void calcMinMax(int start, int end) { if (mValues == null) return; if (mValues.size() == 0) return; int endValue; if (end == 0 || end >= mValues.size()) endValue = mValues.size() - 1; else endValue = end; mYMin = Float.MAX_VALUE; mYMax = -Float.MAX_VALUE; for (int i = start; i <= endValue; i++) { CandleEntry e = mValues.get(i); if (e.getLow() < mYMin) mYMin = e.getLow(); if (e.getHigh() > mYMax) mYMax = e.getHigh(); } }
Example 5
Source File: RealmCandleDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 5 votes |
@Override protected void calcMinMax(CandleEntry e) { if (e.getLow() < mYMin) mYMin = e.getLow(); if (e.getHigh() > mYMax) mYMax = e.getHigh(); calcMinMaxX(e); }
Example 6
Source File: RealmCandleDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 5 votes |
@Override protected void calcMinMaxY(CandleEntry e) { if (e.getHigh() < mYMin) mYMin = e.getHigh(); if (e.getHigh() > mYMax) mYMax = e.getHigh(); if (e.getLow() < mYMin) mYMin = e.getLow(); if (e.getLow() > mYMax) mYMax = e.getLow(); }
Example 7
Source File: CandleStickChart.java From Notification-Analyser with MIT License | 5 votes |
/** * Transforms the values of an entry in order to draw the candle-shadow. * * @param shadowPoints * @param e */ private void transformShadow(float[] shadowPoints, CandleEntry e) { shadowPoints[0] = e.getXIndex() + 0.5f; shadowPoints[1] = e.getHigh() * mPhaseY; shadowPoints[2] = e.getXIndex() + 0.5f; shadowPoints[3] = e.getLow() * mPhaseY; transformPointArray(shadowPoints); }
Example 8
Source File: MyCandleStickChartRenderer.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
@Override public void drawValues(Canvas c) { List<ICandleDataSet> dataSets = mChart.getCandleData().getDataSets(); for (int i = 0; i < dataSets.size(); i++) { ICandleDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet)) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); MyTransformer trans = ((CombinedChartKline) (mChart)).getTransformer(dataSet.getAxisDependency()); mXBounds.set(mChart, dataSet); float[] positions = trans.generateTransformedValuesCandle( dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float[] positionsLow = trans.generateTransformedValuesCandleLow( dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float yOffset = Utils.convertDpToPixel(5f); MyValueFormatter formatter = (MyValueFormatter) dataSet.getValueFormatter(); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); CandleEntry entryMin = dataSet.getEntryForIndex(mXBounds.min); float xMin = positionsLow[0]; float yMin = positionsLow[1]; CandleEntry entryMax = dataSet.getEntryForIndex(mXBounds.min); float xMax = positions[0]; float yMax = positions[1]; for (int j = 0; j < positions.length; j += 2) { float xHigh = positions[j]; float yHigh = positions[j + 1]; float xLow = positionsLow[j]; float yLow = positionsLow[j + 1]; if (!mViewPortHandler.isInBoundsRight(xHigh)) break; if (!mViewPortHandler.isInBoundsLeft(xHigh) || !mViewPortHandler.isInBoundsY(yHigh)) continue; if (!mViewPortHandler.isInBoundsRight(xLow)) break; if (!mViewPortHandler.isInBoundsLeft(xLow) || !mViewPortHandler.isInBoundsY(yLow)) continue; CandleEntry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (entry.getHigh() > entryMax.getHigh()) { entryMax = entry; xMax = xHigh; yMax = yHigh; } if (entry.getLow() < entryMin.getLow()) { entryMin = entry; xMin = xLow; yMin = yLow + yOffset; } } if (dataSet.isDrawValuesEnabled()) { drawValue(c, formatter.getCandleLabel(entryMax), xMax, yMax, ContextCompat.getColor(BaseApplication.getContext(), R.color.kline_red)); drawValue(c, formatter.getCandleLabelLow(entryMin), xMin, yMin, ContextCompat.getColor(BaseApplication.getContext(), R.color.kline_green)); } MPPointF.recycleInstance(iconsOffset); } }
Example 9
Source File: CandleStickChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { final int minDataSetIndex = high.getDataSetIndex() == -1 ? 0 : high.getDataSetIndex(); final int maxDataSetIndex = high.getDataSetIndex() == -1 ? candleData.getDataSetCount() : (high.getDataSetIndex() + 1); if (maxDataSetIndex - minDataSetIndex < 1) continue; for (int dataSetIndex = minDataSetIndex; dataSetIndex < maxDataSetIndex; dataSetIndex++) { int xIndex = high.getXIndex(); // get the // x-position ICandleDataSet set = mChart.getCandleData().getDataSetByIndex(dataSetIndex); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXIndex(xIndex); if (e == null || e.getXIndex() != xIndex) continue; float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; float[] pts = new float[]{ xIndex, y }; mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts); // draw the lines drawHighlightLines(c, pts, set); } } }
Example 10
Source File: CandleStickChart.java From Notification-Analyser with MIT License | 4 votes |
@Override protected void drawHighlights() { for (int i = 0; i < mIndicesToHightlight.length; i++) { int xIndex = mIndicesToHightlight[i].getXIndex(); // get the // x-position CandleDataSet set = mOriginalData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex()); if (set == null) continue; mHighlightPaint.setColor(set.getHighLightColor()); CandleEntry e = set.getEntryForXIndex(xIndex); if(e == null) continue; float low = e.getLow() * mPhaseY; float high = e.getHigh() * mPhaseY; float[] vertPts = new float[] { xIndex, mYChartMax, xIndex, mYChartMin, xIndex + 1f, mYChartMax, xIndex + 1f, mYChartMin }; float[] horPts = new float[] { 0, low, mDeltaX, low, 0, high, mDeltaX, high }; transformPointArray(vertPts); transformPointArray(horPts); // draw the vertical highlight lines mDrawCanvas.drawLines(vertPts, mHighlightPaint); // draw the horizontal highlight lines mDrawCanvas.drawLines(horPts, mHighlightPaint); } }
Example 11
Source File: CandleStickChartRenderer.java From StockChart-MPAndroidChart with MIT License | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) { continue; } CandleEntry e = set.getEntryForXValue(high.getX(), high.getY()); if (!isInBoundsX(e, set)) { continue; } float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y); high.setDraw((float) pix.x, (float) pix.y); // draw the lines drawHighlightLines(c, (float) pix.x, (float) pix.y, set); } }
Example 12
Source File: CandleStickChartRenderer.java From Ticket-Analysis with MIT License | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXValue(high.getX(), high.getY()); if (!isInBoundsX(e, set)) continue; float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y); high.setDraw((float) pix.x, (float) pix.y); // draw the lines drawHighlightLines(c, (float) pix.x, (float) pix.y, set); } }
Example 13
Source File: CandleStickChartRenderer.java From android-kline with Apache License 2.0 | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXValue(high.getX(), high.getY()); if (!isInBoundsX(e, set)) continue; float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y); high.setDraw((float) pix.x, (float) pix.y); // draw the lines drawHighlightLines(c, (float) pix.x, (float) pix.y, set); } }
Example 14
Source File: CandleStickChartRenderer.java From android-kline with Apache License 2.0 | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { CandleData candleData = mChart.getCandleData(); for (Highlight high : indices) { ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXValue(high.getX(), high.getY()); if (!isInBoundsX(e, set)) continue; float lowValue = e.getLow() * mAnimator.getPhaseY(); float highValue = e.getHigh() * mAnimator.getPhaseY(); float y = (lowValue + highValue) / 2f; MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y); high.setDraw((float) pix.x, (float) pix.y); // draw the lines drawHighlightLines(c, (float) pix.x, (float) pix.y, set); } }
Example 15
Source File: CandleStickChartRenderer.java From iMoney with Apache License 2.0 | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { for (int i = 0; i < indices.length; i++) { int xIndex = indices[i].getXIndex(); // get the // x-position CandleDataSet set = mChart.getCandleData().getDataSetByIndex( indices[i].getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXIndex(xIndex); if (e == null || e.getXIndex() != xIndex) continue; float low = e.getLow() * mAnimator.getPhaseY(); float high = e.getHigh() * mAnimator.getPhaseY(); float y = (low + high) / 2f; float min = mChart.getYChartMin(); float max = mChart.getYChartMax(); float[] pts = new float[] { xIndex, y }; mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts); // draw the lines drawHighlightLines(c, pts, set); } }
Example 16
Source File: CandleStickChartRenderer.java From Stayfit with Apache License 2.0 | 3 votes |
@Override public void drawHighlighted(Canvas c, Highlight[] indices) { for (int i = 0; i < indices.length; i++) { int xIndex = indices[i].getXIndex(); // get the // x-position ICandleDataSet set = mChart.getCandleData().getDataSetByIndex( indices[i].getDataSetIndex()); if (set == null || !set.isHighlightEnabled()) continue; CandleEntry e = set.getEntryForXIndex(xIndex); if (e == null || e.getXIndex() != xIndex) continue; float low = e.getLow() * mAnimator.getPhaseY(); float high = e.getHigh() * mAnimator.getPhaseY(); float y = (low + high) / 2f; float min = mChart.getYChartMin(); float max = mChart.getYChartMax(); float[] pts = new float[]{ xIndex, y }; mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts); // draw the lines drawHighlightLines(c, pts, set); } }