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

groupspace doesn't work #919

Closed
channak opened this issue Apr 5, 2016 · 3 comments
Closed

groupspace doesn't work #919

channak opened this issue Apr 5, 2016 · 3 comments

Comments

@channak
Copy link

channak commented Apr 5, 2016

Hi,everyone!! I have two datatsets for the barchart and i try to set groupspace to 0 for the my chartdata but it doesn't work. Could you help?

@liuxuan30
Copy link
Member

what you mean not work? post a screenshot and what groupSpace you set.

@channak
Copy link
Author

channak commented Apr 6, 2016

    var dataEntries: [BarChartDataEntry] = []
    var dataEntries2: [BarChartDataEntry] = []


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

    for i in 0..<dataPoints.count {
        let dataEntry = BarChartDataEntry(value: values2[i], xIndex: i)
        dataEntries2.append(dataEntry)
    }

    let chartDataSet = BarChartDataSet(yVals: dataEntries, label: "Stress Level")
    let chartDataSet2 = BarChartDataSet(yVals: dataEntries2, label: "Stress Label")

    chartDataSet.colors =  [UIColor(red: 255/255, green: 0/255, blue: 0/255, alpha: 1)]
    chartDataSet2.colors =  [UIColor(red: 0/255, green: 255/255, blue: 0/255, alpha: 1)]

    let dataSets: [BarChartDataSet] = [chartDataSet,chartDataSet2]
    let chartData = BarChartData(xVals: daytime, dataSets: dataSets)

    chartData.groupSpace = 0.0
    barChart.data = chartData

12968630_10206344976760244_1714631040_n

what i want is to set no space between all the bar in the graph.
is it possible to do something like this in the bar chart?
12935292_10206344984760444_1175422832_n

@liuxuan30
Copy link
Member

I tested with ChartsDemo with similar code, it works fine. I don't know what you mean from your screenshot.
I guess you misunderstand what groupSpace means. It means the space between each bar groups, which means one xIndex stands for oue bar group, so for two bar data sets, every group will have two bars. e.g. if groupSpace is 4 space with 3 xIndex, the bar looks like ||----||----||, while it's 0, it's just like ||||||
So you just set barSpace and groupSpace to 0.
for single data set, groupSpace works like barSpace, and it's locked as 0.0 if one one set.

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