use of com.github.mikephil.charting.charts.RadarChart in project carat by amplab.
the class PieRadarChartTouchListener method onSingleTapUp.
@Override
public boolean onSingleTapUp(MotionEvent e) {
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
float distance = mChart.distanceToCenter(e.getX(), e.getY());
// check if a slice was touched
if (distance > mChart.getRadius()) {
// if no slice was touched, highlight nothing
mChart.highlightValues(null);
mLastHighlight = null;
} else {
float angle = mChart.getAngleForPoint(e.getX(), e.getY());
int index = mChart.getIndexForAngle(angle);
// check if the index could be found
if (index < 0) {
mChart.highlightValues(null);
mLastHighlight = null;
} else {
ArrayList<SelInfo> valsAtIndex = mChart.getYValsAtIndex(index);
int dataSetIndex = 0;
// has one DataSet)
if (mChart instanceof RadarChart) {
dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, distance / ((RadarChart) mChart).getFactor());
}
Highlight h = new Highlight(index, dataSetIndex);
if (h.equalTo(mLastHighlight)) {
mChart.highlightTouch(null);
mLastHighlight = null;
} else {
mChart.highlightTouch(h);
mLastHighlight = h;
}
}
}
return true;
}
Aggregations