Java Code Examples for com.github.mikephil.charting.data.BarEntry#getYVals()
The following examples show how to use
com.github.mikephil.charting.data.BarEntry#getYVals() .
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: StackedValueFormatter.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public String getBarStackedLabel(float value, BarEntry entry) { if (!mDrawWholeStack) { float[] vals = entry.getYVals(); if (vals != null) { // find out if we are on top of the stack if (vals[vals.length - 1] == value) { // return the "sum" across all stack values return mFormat.format(entry.getY()) + mSuffix; } else { return ""; // return empty } } } // return the "proposed" value return mFormat.format(value) + mSuffix; }
Example 2
Source File: StackedBarsMarkerView.java From StockChart-MPAndroidChart with MIT License | 6 votes |
@Override public void refreshContent(Entry e, Highlight highlight) { if (e instanceof BarEntry) { BarEntry be = (BarEntry) e; if(be.getYVals() != null) { // draw the stack value tvContent.setText(Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true)); } else { tvContent.setText(Utils.formatNumber(be.getY(), 0, true)); } } else { tvContent.setText(Utils.formatNumber(e.getY(), 0, true)); } super.refreshContent(e, highlight); }
Example 3
Source File: StackedValueFormatter.java From Ticket-Analysis with MIT License | 6 votes |
@Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { if (!mDrawWholeStack && entry instanceof BarEntry) { BarEntry barEntry = (BarEntry) entry; float[] vals = barEntry.getYVals(); if (vals != null) { // find out if we are on top of the stack if (vals[vals.length - 1] == value) { // return the "sum" across all stack values return mFormat.format(barEntry.getY()) + mAppendix; } else { return ""; // return empty } } } // return the "proposed" value return mFormat.format(value) + mAppendix; }
Example 4
Source File: StackedValueFormatter.java From android-kline with Apache License 2.0 | 6 votes |
@Override public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { if (!mDrawWholeStack && entry instanceof BarEntry) { BarEntry barEntry = (BarEntry) entry; float[] vals = barEntry.getYVals(); if (vals != null) { // find out if we are on top of the stack if (vals[vals.length - 1] == value) { // return the "sum" across all stack values return mFormat.format(barEntry.getY()) + mAppendix; } else { return ""; // return empty } } } // return the "proposed" value return mFormat.format(value) + mAppendix; }
Example 5
Source File: RealmBarDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 6 votes |
@Override protected void calcMinMax(BarEntry e) { if (e != null && !Float.isNaN(e.getY())) { if (e.getYVals() == null) { if (e.getY() < mYMin) mYMin = e.getY(); if (e.getY() > mYMax) mYMax = e.getY(); } else { if (-e.getNegativeSum() < mYMin) mYMin = -e.getNegativeSum(); if (e.getPositiveSum() > mYMax) mYMax = e.getPositiveSum(); } calcMinMaxX(e); } }
Example 6
Source File: BarHighlighter.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been * selected. * * @param high the Highlight to work with looking for stacked values * @param set * @param xVal * @param yVal * @return */ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) { BarEntry entry = set.getEntryForXValue(xVal, yVal); if (entry == null) { return null; } // not stacked if (entry.getYVals() == null) { return high; } else { Range[] ranges = entry.getRanges(); if (ranges.length > 0) { int stackIndex = getClosestStackIndex(ranges, yVal); MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to); Highlight stackedHigh = new Highlight( entry.getX(), entry.getY(), (float) pixels.x, (float) pixels.y, high.getDataSetIndex(), stackIndex, high.getAxis() ); MPPointD.recycleInstance(pixels); return stackedHigh; } } return null; }
Example 7
Source File: StackedBarActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public void onValueSelected(Entry e, Highlight h) { BarEntry entry = (BarEntry) e; if (entry.getYVals() != null) Log.i("VAL SELECTED", "Value: " + entry.getYVals()[h.getStackIndex()]); else Log.i("VAL SELECTED", "Value: " + entry.getY()); }
Example 8
Source File: BarHighlighter.java From Ticket-Analysis with MIT License | 5 votes |
/** * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been * selected. * * @param high the Highlight to work with looking for stacked values * @param set * @param xVal * @param yVal * @return */ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) { BarEntry entry = set.getEntryForXValue(xVal, yVal); if (entry == null) return null; // not stacked if (entry.getYVals() == null) { return high; } else { Range[] ranges = entry.getRanges(); if (ranges.length > 0) { int stackIndex = getClosestStackIndex(ranges, yVal); MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to); Highlight stackedHigh = new Highlight( entry.getX(), entry.getY(), (float) pixels.x, (float) pixels.y, high.getDataSetIndex(), stackIndex, high.getAxis() ); MPPointD.recycleInstance(pixels); return stackedHigh; } } return null; }
Example 9
Source File: BarHighlighter.java From android-kline with Apache License 2.0 | 5 votes |
/** * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been * selected. * * @param high the Highlight to work with looking for stacked values * @param set * @param xVal * @param yVal * @return */ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal, float yVal) { BarEntry entry = set.getEntryForXValue(xVal, yVal); if (entry == null) return null; // not stacked if (entry.getYVals() == null) { return high; } else { Range[] ranges = entry.getRanges(); if (ranges.length > 0) { int stackIndex = getClosestStackIndex(ranges, yVal); MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to); Highlight stackedHigh = new Highlight( entry.getX(), entry.getY(), (float) pixels.x, (float) pixels.y, high.getDataSetIndex(), stackIndex, high.getAxis() ); MPPointD.recycleInstance(pixels); return stackedHigh; } } return null; }