-
-
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 delegate not called #1669
Comments
Here is the tapGesture function, am I missing something?
|
check your /// Highlights the value selected by touch gesture.
open func highlightValue(_ highlight: Highlight?, callDelegate: Bool)
{
var entry: ChartDataEntry?
var h = highlight
if h == nil
{
_indicesToHighlight.removeAll(keepingCapacity: false)
}
else
{
// set the indices to highlight
entry = _data?.entryForHighlight(h!)
if entry == nil
{
h = nil
_indicesToHighlight.removeAll(keepingCapacity: false)
}
else
{
_indicesToHighlight = [h!]
}
}
if callDelegate && delegate != nil
{
if h == nil
{
delegate!.chartValueNothingSelected?(self)
}
else
{
// notify the listener
delegate!.chartValueSelected?(self, entry: entry!, highlight: h!)
}
}
// redraw the chart
setNeedsDisplay()
} |
Hi @liuxuan30 , This part of code you mentioned functions well. I set breakpoint at
and it breaks correctly if I have highlight object. but it cannot link to
in my controller. |
Please read the #1474 migration notes. The |
override func viewDidLoad() {
delet dataSetIndex: Int |
You must use func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) { ... } instead! |
hamz250 is right. Swift delegate method signature has changed, thats why you need to implement the method with the header: func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) { The key here is _ (underscore) before the chartView: |
i have same signature but still method is not called at all |
pieChartView needs to have highlightPerTapEnabled = true to call delegate method: func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
...
} look at PieRadarCharViewBase.swift: @objc private func tapGestureRecognized(_ recognizer: NSUITapGestureRecognizer)
{
if recognizer.state == NSUIGestureRecognizerState.ended
{
----> if !self.isHighLightPerTapEnabled { return } <-----
let location = recognizer.location(in: self)
let high = self.getHighlightByTouchPoint(location)
self.highlightValue(high, callDelegate: true)
}
} and @objc open var isHighLightPerTapEnabled: Bool
{
return highlightPerTapEnabled
} |
I've read issue #695 and I have the same problem. Since I don't understand step 3 in the answer "3. whether pie chart view has detect your gesture (simply add bp inside @objc private func tapGestureRecognized in PieRadarChartViewBase)", I post my issue here.
My chart is rendered correctly and it has user interactions like tap and pinch zoom. Also chart is able to detect my tap gesture. But somehow
cannot be called. Really need some help here.
What I want to implement is that both balloon mark with same X value would show if I click on either a bar or a point on line. (both mark in above two pictures will display at same time when I tap a bar or a point)
Below is my entire controller code:
The text was updated successfully, but these errors were encountered: