Skip to content
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

Cannot invoke initializer for type 'PieChartData' error in Swift 2.3 #1400

Closed
sashalondon opened this issue Sep 6, 2016 · 4 comments
Closed

Comments

@sashalondon
Copy link

I have updated to Swift 2.3 and have this error. I cannot figure it out and it was working before:

```
// MARK: - pie chart

func setChart(dataPoints: [String], values: [Double]) {

var dataEntries: [ChartDataEntry] = []

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

let pieChartDataSet = PieChartDataSet(values: dataEntries, label: "Bowel Movements")
let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
pieChartView.data = pieChartData

pieChartDataSet.colors = GlobalColourConstants.bMColourTableArray
}

I get the following errors. 
(https://cloud.githubusercontent.com/assets/8496722/18268851/7f53320e-741d-11e6-8f68-60c98f127e3b.jpg)

Cannot convert value of type 'Int' to expected argument type 'Double'

Cannot invoke initializer for type 'PieChartData' with an argument list of type '(xVals: [String], dataSet: PieChartDataSet)'

Any help is appreciated!
@danielgindi
Copy link
Collaborator

You have moved to Charts 3.0.
Latest compatible release is 2.2.5.
When the 3.0 release will be final and official - we'll add notes on how to migrate

@sashalondon
Copy link
Author

Ok thank you.

@liuxuan30
Copy link
Member

there are swift 2.3 branch for you, for both Chart 2.x release and 3 code.

@prakasha-maravanthe
Copy link

prakasha-maravanthe commented Dec 6, 2016

LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)

The Above line gives error which I am not able to figure it out and tried to find solution to the problem and not able to find any...

I am trying to use Piechart and Line chart from Git Hub.

Xcode 8.1 and Swift 3.0 And iOS 10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants