Skip to content

On Touch-Event is invoked on all series if more then one point is next to the tap #500

Description

@georgh

I use the listener to make the tapped point bigger and display a snackbar.
Only the snackbar of the series added last to the graph is displayed.

Reason for this behaviour is the handling of onTouchEvent in Graphview:

    public boolean onTouchEvent(MotionEvent event) {
        boolean b = mViewport.onTouchEvent(event);
        boolean a = super.onTouchEvent(event);

        // is it a click?
        if (mTapDetector.onTouchEvent(event)) {
            for (Series s : mSeries) {
                s.onTap(event.getX(), event.getY());
            }
            if (mSecondScale != null) {
                for (Series s : mSecondScale.getSeries()) {
                    s.onTap(event.getX(), event.getY());
                }
            }
        }

if two points in two different series have a distance less then 120 to the tap both listeners will be called, because s.onTap(event.getX(), event.getY()); only knows the points of its own series and will call its listener if one point has a distance < 120.
I guess sometimes this may be the expected behaviour, but I dont know if this should be the default behaviour.
Whats your thoughts on this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions