Java Code Examples for com.github.mikephil.charting.utils.Utils#getMinimumDistance()
The following examples show how to use
com.github.mikephil.charting.utils.Utils#getMinimumDistance() .
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: ChartHighlighter.java From iMoney with Apache License 2.0 | 3 votes |
/** * Returns the corresponding dataset-index for a given xIndex and xy-touch position in pixels. * * @param xIndex * @param x * @param y * @return */ protected int getDataSetIndex(int xIndex, float x, float y) { List<SelectionDetail> valsAtIndex = getSelectionDetailsAtIndex(xIndex); float leftdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.LEFT); float rightdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.RIGHT); YAxis.AxisDependency axis = leftdist < rightdist ? YAxis.AxisDependency.LEFT : YAxis.AxisDependency.RIGHT; int dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, y, axis); return dataSetIndex; }
Example 2
Source File: ChartHighlighter.java From Stayfit with Apache License 2.0 | 3 votes |
/** * Returns the corresponding dataset-index for a given xIndex and xy-touch position in pixels. * * @param xIndex * @param x * @param y * @return */ protected int getDataSetIndex(int xIndex, float x, float y) { List<SelectionDetail> valsAtIndex = getSelectionDetailsAtIndex(xIndex); float leftdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.LEFT); float rightdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.RIGHT); YAxis.AxisDependency axis = leftdist < rightdist ? YAxis.AxisDependency.LEFT : YAxis.AxisDependency.RIGHT; int dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, y, axis); return dataSetIndex; }
Example 3
Source File: ChartHighlighter.java From NetKnight with Apache License 2.0 | 3 votes |
/** * Returns the corresponding SelectionDetail for a given xIndex and y-touch position in pixels. * * @param xIndex * @param y * @param dataSetIndex * @return */ protected SelectionDetail getSelectionDetail(int xIndex, float y, int dataSetIndex) { List<SelectionDetail> valsAtIndex = getSelectionDetailsAtIndex(xIndex, dataSetIndex); float leftdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.LEFT); float rightdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.RIGHT); YAxis.AxisDependency axis = leftdist < rightdist ? YAxis.AxisDependency.LEFT : YAxis.AxisDependency.RIGHT; SelectionDetail detail = Utils.getClosestSelectionDetailByPixelY(valsAtIndex, y, axis); return detail; }