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

Bar Chart view group in Swift #551

Closed
brytnvmg opened this issue Nov 14, 2015 · 4 comments
Closed

Bar Chart view group in Swift #551

brytnvmg opened this issue Nov 14, 2015 · 4 comments

Comments

@brytnvmg
Copy link

Error : cannot invoke initializer for type with an argument list of type !!!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let 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, 4.0]
let unitsSold2 = [25.0, 2.0, 4.0, 10.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]
setChart(months, values: unitsSold, values2: unitsSold2)
}

func setChart(dataPoints: [String], values: [Double], values2: [Double]) {
    barChartView.noDataText = "You need to provide data for the chart."
    var dataEntries1: [BarChartDataEntry] = []
    var dataEntries2: [BarChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry1 = BarChartDataEntry(value: values[i], xIndex: i)

        let dataEntry2 = BarChartDataEntry(value: values2[i], xIndex: i)
        dataEntries1.append(dataEntry1)
        dataEntries2.append(dataEntry2)
    }

    let chartDataSet1 = BarChartDataSet(yVals: dataEntries1, label: "Units Sold")
    let chartDataSet2 = BarChartDataSet(yVals: dataEntries2, label: "Units Sold 2")
    var dataSet : [BarChartDataSet] = [BarChartDataSet]()
    dataSet.append(chartDataSet1)
    dataSet.append(chartDataSet2)


    let chartData = BarChartData(xVals: dataPoints, dataSet: dataSet) ->> 
    ->> Error : cannot invoke initializer for type with an argument list of type !!!


    chartData.groupSpace = 1
    barChartView.data = chartData
}
@victors1681
Copy link

chage dataSet to dataSets "Add S"
let chartData = BarChartData(xVals: dataPoints, dataSets: dataSet) ->>
->> Error : cannot invoke initializer for type with an argument list of type !!!

@zhydanovajulia
Copy link

+1

@sangle-umesh
Copy link

sangle-umesh commented Dec 6, 2016

 let chartData = BarChartData()
    chartData.addDataSet(chartDataSet)
    barChartView.data = chartData

this helped me in my case

@Sikandarkhan
Copy link

let chartData = BarChartData()
chartData.addDataSet(chartDataSet)
barChartView.data = chartData

this worked for me.

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

5 participants