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

Migration to Chart 3.0, Problem with Stack BarChartView #1925

Closed
amitvyawahare opened this issue Dec 6, 2016 · 1 comment
Closed

Migration to Chart 3.0, Problem with Stack BarChartView #1925

amitvyawahare opened this issue Dec 6, 2016 · 1 comment

Comments

@amitvyawahare
Copy link

amitvyawahare commented Dec 6, 2016

Thank for the beautiful library!

I was using Charts 2.3.0 version for my stack bar chart view. But after I moved to Swift 3 and Chart 3.0, then my code started breaking. After fixing the number of problems, I am having one issues.

Code I am using
` func setChart() {

    let entry1 = BarChartDataEntry(x: 1, yValues: [ 3, 0, 0, 0])
    let entry2 = BarChartDataEntry(x: 2, yValues: [ 0, 8, 0, 0])
    let entry3 = BarChartDataEntry(x: 3, yValues: [ 12, 0, 0, 4])
    let entry4 = BarChartDataEntry(x: 4, yValues: [ 0, 5, 0, 0])
    let entry5 = BarChartDataEntry(x: 5, yValues: [ 4, 6, 2, 8])
    
    let dataSet = BarChartDataSet(values: [ entry1, entry2, entry3, entry4, entry5], label: "")
    dataSet.colors = [ UIColor.yellow, UIColor.green, UIColor.blue, UIColor.darkGray]
    dataSet.valueColors = [ UIColor.white]
    
    let chartData = BarChartData(dataSet: dataSet)
    barChartView.data = chartData
}`

Output:
screen shot 2016-12-06 at 5 33 29 pm

` func setChart() {

    let entry1 = BarChartDataEntry(x: 1.1, yValues: [ 3, 0, 0, 0])
    let entry2 = BarChartDataEntry(x: 1.2, yValues: [ 0, 8, 0, 0])
    let entry3 = BarChartDataEntry(x: 1.3, yValues: [ 12, 0, 0, 4])
    let entry4 = BarChartDataEntry(x: 1.4, yValues: [ 0, 5, 0, 0])
    let entry5 = BarChartDataEntry(x: 1.5, yValues: [ 4, 6, 2, 8])
    
    let dataSet = BarChartDataSet(values: [ entry1, entry2, entry3, entry4, entry5], label: "")
    dataSet.colors = [ UIColor.yellow, UIColor.green, UIColor.blue, UIColor.darkGray]
    dataSet.valueColors = [ UIColor.white]
    
    let chartData = BarChartData(dataSet: dataSet)
    barChartView.data = chartData
}`

screen shot 2016-12-06 at 5 33 46 pm

My issues is:

  1. When I change x value in BarChartDataEntry from 1,2,3,4,5 to 1.1,1.2,1.3,1.4,1.5, stack bar chart giving me very wired behavior. Screen shot is attached. So my question is how do I make use BarChartDataEntry to use Double x value. It used to work fine in 2.3 version because XValues are string (Used to use: (xVals: [ "1.1", "1.2", "1.3", "1.4" ], dataSet: dataSet)).

In chart 3.0, we have a init with label for stacked bar entries but that label doesn't show anywhere.
I am ok with if following code works and label("1.1") shows on xAxis
let entry1 = BarChartDataEntry(x: 1, yValues: [ 3, 0, 0, 0], label: "1.1")

@liuxuan30
Copy link
Member

you need to read #1474 first. x axis is redesigned. And check ChartsDemo.

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