无法使用类型为Error的参数调用类型的初始化程序

时间:2017-07-09 07:46:14

标签: ios swift charts

我收到错误

  

无法为类型为(xVals: [String]!, dataSet: BarChartDataSet)

的参数列表的类型调用初始化程序

在突出显示的行上显示以下代码。你能让我知道如何解决这个问题。

var months: [String]!
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 9.0]
var dataEntries: [BarChartDataEntry] = []

  for i in 0..<dataPoints.count {            
      let dataEntry = BarChartDataEntry(x: Double(i), y:values[i])
      dataEntries.append(dataEntry)
  }

  let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold")
  let chartData = BarChartData(xVals: months, dataSet: chartDataSet) //Error on this line       
  barChartView.data = chartData

0 个答案:

没有答案