Search code examples
swiftios-charts

ios-charts: Can Selecting A Node Trigger A Labels Text To Change?


I am using ios-charts in swift language. I'm wanting to show more data about each node when they are selected. A marker wouldn't have enough space for all the info I am wanting to display so I am wanting to display it all in a dedicated label on the ViewController itself. Is there any way to do this?

I got the chartValueSelected method working but am not sure how to utilize it for this.


Solution

  • Included ChartViewDelegate

    &

     chtChart.delegate = self
    

    I have an array called textNotes thats corresponds to each data entry in the array and made a label called infoLabelChart

        func chartValueSelected(_ chartView: ChartViewBase, entry: 
        ChartDataEntry, highlight: Highlight) {
            let pos = NSInteger(entry.x)
            infoLabelChart.text = "\(textNotes[pos])"
        }