-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
ChartValueSelected Only While Finger Pressed #1234
Comments
so when the value is highlighted, this delegate gets called. So if you tap or scroll, it will get called many times. I don't know what are you trying to achieve. If you don't like scroll + highlight, just disable the pan gesture. |
Hi Liuxuan30, I like the scrolling + highlight feature, I am just looking for the highlight to go away/disable once my finger has been lifted from the screen. Currently, with the snippet of code I posted, when I touch my finger to the graph (can scroll), the highlight comes up and shows my selection. However, once I remove my finger from the graph, the highlight still stays there. I am looking for the highlight to disappear once I raise my finger from the screen. I apologize for not wording my question very well |
hmm.. I see.. I guess you have to look at the gesture handler code to provide a custom one. |
That's what I was thinking; do you happen to know which file that would likely be located in so I can try to mess around with it, please? Thanks! |
BarLineChartViewBase.swift, search handler |
Were you able to figure out a solution to this issue? I have been messing around with the ChartHighlighter and BarLineChartViewBase classes, but I haven't been able to catch any "gesture end" events. |
@sinnott-balin I have not figured it out. I'm wondering if you could simulate a double-tap somewhere on the screen (either the current area selected, or the top left corner of the graph [would select that area really quickly, then deselect it]). Not the best solution, but seems it might be a temporary fix |
@jdulb17 yes adding your own tap gesture recognizer should work as long as you are catching taps on a different view. I think adding your own gesture recognizer to the line chart itself will overwrite the default gesture recognizer. Inside BarLineChartViewBase there is a method called "panGestureRecognized" which handles all of the pan gesture events. Is it possible to subclass BarLineChartViewBase and override this method to remove highlights when recognizer.state == Ended? |
Any updates on this? A pan gesture recognizer on the chart does not work, nor does a gesture recognizer on the containing view. |
Any updates on this? |
I think I got it. |
@rathodmayur93 nice! do you have any idea on how you'd implement this for chartValueNothingSelected? That doesn't seem to work either haha |
@OhBehive chartValueNothingSelected didn't work for me as well. So I tried an alternative method |
Disable the bar chart view's drag gestures. Then it will detect only your tap actions (chartValueSelected). It works for me.
Hope it helps |
@danielgindi I am also facing same issue , i need drag as well in my code for BarChart but it seems there is not track after lift finger from bar. like in line chart it will call |
Hello, I came across this code snippet:
func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: ChartHighlight) {
print("\(entry.value) in \(dates[entry.xIndex])")
}
And was looking to tweak it where it only selected the value while my finger was pressed. Is this possible? I noticed there is a chartValueNothingSelected method that can be implemented when you double tap the chart, but ideally I'd like it to execute when the finger is lifted from the screen/chart. Thanks!
The text was updated successfully, but these errors were encountered: