Use of unresolved identifier "value" in SwiftCharts

85 Views Asked by At

I'm trying to implement the touch to show the current value. The problem is that I'm getting use of unresolved identifier "value" when I try to add the text to my label. The series are shown correctly in the Chart but I'm not getting the value inside the indexes.

func didTouchChart(_ chart: Chart, indexes: [Int?], x: Float, left: CGFloat) {
        if dataResponse.count > 0 {
            for (seriesIndex, dataIndex) in indexes.enumerated() {

              if dataIndex != nil {
                // The series at `seriesIndex` is that which has been touched

                let value = chart.valueForSeries(seriesIndex, atIndex: dataIndex)
                let date = dataDates[dataIndex!]
                let type = SensorType.getSpecialCharacter(sensorTypes[dataIndex!])
                lblValue.text = "\(value)\(type) \(date)" //Ex. 78°C 12-11-2018
              }

            }
        }

    }

It used to work fine before, but I don't know what happened. I don't know what could be happening, I was expecting this behavior. 660d660e-9adc-11e5-8a67-0c3036c20862

After a couple of runs and cleans the error changed to Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file. I must say I don't have any file variable nor class in my code.

0

There are 0 best solutions below