Java Code Examples for com.github.mikephil.charting.highlight.Highlight#equalTo()

The following examples show how to use com.github.mikephil.charting.highlight.Highlight#equalTo() . 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: BarLineChartTouchListener.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 *
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightValue(h, true);
    }
}
 
Example 2
Source File: ChartTouchListener.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
/**
 * Perform a highlight operation.
 *
 * @param e
 */
protected void performHighlight(Highlight h, MotionEvent e) {

    if (h == null || h.equalTo(mLastHighlighted)) {
        mChart.highlightValue(null, true);
        mLastHighlighted = null;
    } else {
        mChart.highlightValue(h, true);
        mLastHighlighted = h;
    }
}
 
Example 3
Source File: BarLineChartTouchListener.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 *
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightValue(h, true);
    }
}
 
Example 4
Source File: ChartTouchListener.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
/**
 * Perform a highlight operation.
 *
 * @param e
 */
protected void performHighlight(Highlight h, MotionEvent e) {

    if (h == null || h.equalTo(mLastHighlighted)) {
        mChart.highlightValue(null, true);
        mLastHighlighted = null;
    } else {
        mChart.highlightValue(h, true);
        mLastHighlighted = h;
    }
}
 
Example 5
Source File: BarLineChartTouchListener.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 *
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightValue(h, true);
    }
}
 
Example 6
Source File: ChartTouchListener.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Perform a highlight operation.
 *
 * @param e
 */
protected void performHighlight(Highlight h, MotionEvent e) {

    if (h == null || h.equalTo(mLastHighlighted)) {
        mChart.highlightValue(null, true);
        mLastHighlighted = null;
    } else {
        mChart.highlightValue(h, true);
        mLastHighlighted = h;
    }
}
 
Example 7
Source File: BarLineChartTouchListener.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * Perform a highlight operation.
 * 
 * @param e
 */
private void performHighlight(MotionEvent 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);
    }
}
 
Example 8
Source File: BarLineChartTouchListener.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 * 
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightTouch(h);
    }
}
 
Example 9
Source File: BarLineChartTouchListener.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 * 
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightTouch(h);
    }
}
 
Example 10
Source File: ChartTouchListener.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * Perform a highlight operation.
 *
 * @param e
 */
protected void performHighlight(Highlight h, MotionEvent e) {

    if (h == null || h.equalTo(mLastHighlighted)) {
        mChart.highlightTouch(null);
        mLastHighlighted = null;
    } else {
        mLastHighlighted = h;
        mChart.highlightTouch(h);
    }
}
 
Example 11
Source File: BarLineChartTouchListener.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights upon dragging, generates callbacks for the selection-listener.
 *
 * @param e
 */
private void performHighlightDrag(MotionEvent e) {

    Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());

    if (h != null && !h.equalTo(mLastHighlighted)) {
        mLastHighlighted = h;
        mChart.highlightValue(h, true);
    }
}
 
Example 12
Source File: ChartTouchListener.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
/**
 * Perform a highlight operation.
 *
 * @param e
 */
protected void performHighlight(Highlight h, MotionEvent e) {

    if (h == null || h.equalTo(mLastHighlighted)) {
        mChart.highlightValue(null, true);
        mLastHighlighted = null;
    } else {
        mChart.highlightValue(h, true);
        mLastHighlighted = h;
    }
}
 
Example 13
Source File: PieRadarChartTouchListener.java    From iMoney with Apache License 2.0 4 votes vote down vote up
@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);
        mLastHighlighted = null;

    } else {

        float angle = mChart.getAngleForPoint(e.getX(), e.getY());

        if (mChart instanceof PieChart) {
            angle /= mChart.getAnimator().getPhaseY();
        }

        int index = mChart.getIndexForAngle(angle);

        // check if the index could be found
        if (index < 0) {

            mChart.highlightValues(null);
            mLastHighlighted = null;

        } else {

            List<SelectionDetail> valsAtIndex = mChart.getSelectionDetailsAtIndex(index);

            int dataSetIndex = 0;

            // get the dataset that is closest to the selection (PieChart
            // only
            // has one DataSet)
            if (mChart instanceof RadarChart) {

                dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, distance
                        / ((RadarChart) mChart).getFactor(), null);
            }

            if (dataSetIndex < 0) {
                mChart.highlightValues(null);
                mLastHighlighted = null;
            } else {
                Highlight h = new Highlight(index, dataSetIndex);

                if (h.equalTo(mLastHighlighted)) {

                    mChart.highlightTouch(null);
                    mLastHighlighted = null;
                } else {

                    mChart.highlightTouch(h);
                    mLastHighlighted = h;
                }
            }
        }
    }

    return true;
}