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

no match color bar chart with label #1900

Closed
osj8876 opened this issue Dec 1, 2016 · 1 comment
Closed

no match color bar chart with label #1900

osj8876 opened this issue Dec 1, 2016 · 1 comment

Comments

@osj8876
Copy link

osj8876 commented Dec 1, 2016

hello

I draw the bar chart with label.

But bar charts of all is a blue.

Each represented a different color.

It is a bug?

Below the code :

    var yVals = [BarChartDataEntry]()
    
    let dataFormatter = DateFormatter()
    dataFormatter.locale = Locale(identifier: "en_US")
    dataFormatter.dateStyle = .medium
    dataFormatter.dateFormat = "MMM dd"
    
    for i in 0..<data.count - 1 {
        let readData = data[i][1]
        yVals.append(BarChartDataEntry(x: Double(i), y: Double(readData)!))
    }
    
    let todayTime = dataFormatter.date(from: data[data.count-1][0])
    let tommorrowTime = dataFormatter.date(from: data[data.count-1][1])
    let dayAfterTommorrowtodayTime = dataFormatter.date(from: data[data.count-1][2])
    
    dataFormatter.dateFormat = "yyyy-MM-dd"
    
    var convertTime = dataFormatter.string(from: todayTime!)
    
    let dataSetToday = BarChartDataSet(values: yVals, label: convertTime)
    dataSetToday.colors = [UIColor.lightGray]
    
    for i in 0..<data.count - 1 {
        let readData = data[i][2]
        yVals.append(BarChartDataEntry(x: Double(i+9), y: Double(readData)!))
    }
        
    convertTime = dataFormatter.string(from: tommorrowTime!)
        
    let dataSetT​ommorrow = BarChartDataSet(values: yVals, label: convertTime)
    dataSetT​ommorrow.colors = [UIColor.red]
        
    for i in 0..<data.count - 1 {
        let readData = data[i][3]
        yVals.append(BarChartDataEntry(x: Double(i+18), y: Double(readData)!))
    }
        
    convertTime = dataFormatter.string(from: dayAfterTommorrowtodayTime!)
        
    let dataSetDayAfterTommorrow = BarChartDataSet(values: yVals, label: convertTime)
    dataSetDayAfterTommorrow.colors = [UIColor.blue]
        
    let dataSets: [BarChartDataSet] = [dataSetToday, dataSetT​ommorrow, dataSetDayAfterTommorrow]
    
    self.magneticForcastBarView.fitBars = true
    self.magneticForcastBarView.data = BarChartData(dataSets: dataSets)
    self.magneticForcastBarView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBounce)

thank you
kakaotalk_photo_2016-12-01-16-21-21

@liuxuan30
Copy link
Member

dataSetDayAfterTommorrow.colors = [UIColor.blue]
you set it all blue and you ask why..

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

2 participants