use of com.github.mikephil.charting.interfaces.OnChartGestureListener in project carat by amplab.
the class BarLineChartTouchListener method onSingleTapUp.
@Override
public boolean onSingleTapUp(MotionEvent e) {
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());
if (h == null || h.equalTo(mLastHighlighted)) {
mChart.highlightTouch(null);
mLastHighlighted = null;
} else {
mLastHighlighted = h;
mChart.highlightTouch(h);
}
return super.onSingleTapUp(e);
}
use of com.github.mikephil.charting.interfaces.OnChartGestureListener 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;
}
use of com.github.mikephil.charting.interfaces.OnChartGestureListener in project carat by amplab.
the class BarLineChartTouchListener method onDoubleTap.
@Override
public boolean onDoubleTap(MotionEvent e) {
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartDoubleTapped(e);
return super.onDoubleTap(e);
}
// check if double-tap zooming is enabled
if (mChart.isDoubleTapToZoomEnabled()) {
PointF trans = getTrans(e.getX(), e.getY());
mChart.zoom(1.4f, 1.4f, trans.x, trans.y);
Log.i("BarlineChartTouch", "Double-Tap, Zooming In, x: " + trans.x + ", y: " + trans.y);
}
return super.onDoubleTap(e);
}
Aggregations