Search in sources :

Example 1 with OnChartGestureListener

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);
}
Also used : Highlight(com.github.mikephil.charting.utils.Highlight) OnChartGestureListener(com.github.mikephil.charting.interfaces.OnChartGestureListener)

Example 2 with OnChartGestureListener

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;
}
Also used : Highlight(com.github.mikephil.charting.utils.Highlight) OnChartGestureListener(com.github.mikephil.charting.interfaces.OnChartGestureListener) RadarChart(com.github.mikephil.charting.charts.RadarChart) SelInfo(com.github.mikephil.charting.utils.SelInfo)

Example 3 with OnChartGestureListener

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);
}
Also used : OnChartGestureListener(com.github.mikephil.charting.interfaces.OnChartGestureListener) PointF(android.graphics.PointF)

Aggregations

OnChartGestureListener (com.github.mikephil.charting.interfaces.OnChartGestureListener)3 Highlight (com.github.mikephil.charting.utils.Highlight)2 PointF (android.graphics.PointF)1 RadarChart (com.github.mikephil.charting.charts.RadarChart)1 SelInfo (com.github.mikephil.charting.utils.SelInfo)1