chartValueSelected never gets called


I utilize <a href="https://github.com/danielgindi/Charts" rel="nofollow">https://github.com/danielgindi/Charts</a> in my project.

Here is my code, this is how I declare my ViewController class:

class ViewController: UIViewController, ChartViewDelegate

declaration of chartView

@IBOutlet weak var chartView: LineChartView!

inside viewDidLoad()

self.chartView.delegate = self

and this is how I implement delegate method

func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: Highlight) { print(dataSetIndex) }

For some reason, when I swipe across the chart, this method never gets called. Any ideas why this might happen?

Thanks in advance


As I may have expected, the problem was Swift 3 difference in method signature.

<strong>Swift 3</strong>

func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) { ... }


Check with a breakpoint if chatView is initialized in viewDidLoad and check its delegate, then check if the method which call the delegate has ever been called. You can use po chartView.delegate in the terminal screen Maybe you are not selecting the chart, this is not a touch up inside button, to call the selected method you have to set selected, if you want this to work like a button maybe there are an action called setHighlighted...


  • Pass data Through segue not working in swift 3 any solution?
  • Swift - Constraints issue in expandable TableViewCell
  • How to make the cancel button in alert cancel the action?
  • Compiling large array literal in Xcode 8.2
  • Can't log Swift Singletons from Objective-C in Xcode Console
  • UITableView scroll to specific section using UIPIckerView?
  • Xcode - Cannot Adopt Protocol
  • iOS Swift 2.0 UITextView freezes app depending on text
  • How to create a customized rounded UiView and UIButton like MobilePASS?
  • Cant use TabBar delegate methods
  • Autoresize UIScrollView
  • How to send multiple buttons in button.addTarget action? Swift3
  • How to set image position programaticall in objective c?
  • xcode: Using a UIImageView subclass with NSTimers
  • Synchronizing issue with delays in loops
  • Fit entire Google Map in zoom level in Swift project
  • Working on custom component: subclass UIView or UIViewController?
  • iOS/Swift: in which function between viewDidLoad and viewWillAppear am I supposed to query a databas
  • How to swipe multi buttons with one touch
  • Deselect table view row when returning to app
  • Swift 3, iOS 10.3 - Preload UIWebView during Launch Screen
  • How to pass the selected data back to previous view controller
  • error with Xcode 6 'Duplicate interface definition for class 'ViewController'
  • Avoid UIWebView load iTunes App
  • Realm notifications that capture [weak self] in Swift
  • Moving cursor at beginning UItextview [duplicate]
  • Transferring data to another controller with segue. From the code
  • Set UITableView BackgroundColor Universally with UIAppearance
  • View Controller Loads Twice - How Do I Fix It?
  • UIBarButtonItem - Argument of '#selector' cannot refer to local function - Swift 3
  • updatesearchresultsforsearchcontroller not called
  • windowScriptObject method not found on Objective-C code
  • Printing input from TextField to a Label in Xcode with Swift
  • android google indoor map
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Django simple Captcha “No module named fields” error
  • C# - Serializing and deserializing static member
  • Bug in WPF DataGrid
  • Incrementing object id automatically JS constructor (static method and variable)