Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove marker programatically #1097

Closed
chandraf22 opened this issue Jun 1, 2016 · 5 comments
Closed

How to remove marker programatically #1097

chandraf22 opened this issue Jun 1, 2016 · 5 comments

Comments

@chandraf22
Copy link

Hi, I need to remove marker when my touch ends. Is there any way to achieve this?

Also if possible remove marker when ever I want, as my chart is shown in a tableview, the marker is seen even I scroll out of the graph and come back to it, I want to remove it as soon as the user is not interested in the chart.
Please help.

@liuxuan30
Copy link
Member

liuxuan30 commented Jun 2, 2016

hmm, with my PR #887 getting merged, there is a chance to turn off the marker value, can it solve your problem?

@chandraf22
Copy link
Author

@liuxuan30 No, this is not addressing my scenario, but I did some tweaking in BarLineChartViewBase.swift and in ChartViewBase.swift, like making a separate public function for removing the highlighted markers, then overriding nstouchesbegan, nstouchesended and nstouchescnacled functions in BarLineChartViewBase.swift to handle markers. Some how thats what I needed for this scenario. Still removing markers for tableview scroll is not yet achieved.

@xradeon
Copy link

xradeon commented Jun 8, 2016

Yep, wishing for this functionality too..

@zierka
Copy link

zierka commented Jul 13, 2016

You can hook into BarLineChartViewBase's UIPanGestureRecognizer:

if let gestureRecognizers = gestureRecognizers {
    for recognizer in gestureRecognizers {
        if recognizer is UIPanGestureRecognizer {
            recognizer.addTarget(self, action: #selector(hideMarker(_:)))
        }
    }
}

Then in hideMarker method:

func hideMarker(recognizer: UIPanGestureRecognizer) {
    if recognizer.state == .Ended || recognizer.state == .Cancelled {
        highlightValue(nil) // this hides the marker
    }
}

On tableView scroll you just call highlightValue(nil)

@jk9958
Copy link

jk9958 commented Nov 29, 2016

Call this when you want to remove marker from chartview

yourChartViewInstance.highlightValue(nil, callDelegate: false)

@jjatie jjatie closed this as completed Apr 1, 2018
@ChartsOrg ChartsOrg locked as resolved and limited conversation to collaborators Apr 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants