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

Problem with the xValue begins at 0 #1547

Closed
chuynadamas opened this issue Sep 24, 2016 · 4 comments
Closed

Problem with the xValue begins at 0 #1547

chuynadamas opened this issue Sep 24, 2016 · 4 comments
Labels

Comments

@chuynadamas
Copy link
Contributor

Hi @liuxuan30 @danielgindi !

I just found a new kind of issue with the bar charts, I have a little set with 12 groups of bars, every group has two bars. Now I'm setting my groups since the x = 0.

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

As you can see here in the image the last element is not completely drawing over the chart check the black rectangle.

screen shot 2016-09-23 at 5 07 39 pm

I'm using the last commit over master, which is 180c418 and i guess the problem is the same function that before, in this case over the BarChartView

    internal override func calcMinMax()
    {
        guard let data = self.data as? BarChartData
            else { return }

        if fitBars
        {
            _xAxis.calculate(
                min: data.xMin - data.barWidth / 2.0,
                max: data.xMax + data.barWidth / 2.0)
        }
        else
        {
            _xAxis.calculate(min: data.xMin, max: data.xMax)
        }

        // calculate axis range (min / max) according to provided data
        _leftAxis.calculate(
            min: data.getYMin(axis: .left),
            max: data.getYMax(axis: .left))
        _rightAxis.calculate(
            min: data.getYMin(axis: .right),
            max: data.getYMax(axis: .right))
    }

The data.xMax is just taking acount of the last element in x wich is 11 ( counting the 0 as 1 ) and that's the reason why at the end the chart is clipping the last groups of bars. This is just my first assumption please tell me if you think that the problem is in another side.

Thanks in advance.

@liuxuan30
Copy link
Member

tried fitBars = true?

@chuynadamas
Copy link
Contributor Author

chuynadamas commented Sep 26, 2016

Hi, @liuxuan30 I'm using that property :) but the problem stills there :(

In fact that property works well with the left side of the chart, you can see the little span between the axis and the first bar

@liuxuan30 liuxuan30 added the bug label Sep 27, 2016
@liuxuan30
Copy link
Member

:( one more bug.. though I didn't see it in ChartsDemo

@danielgindi
Copy link
Collaborator

Pull the latest master please, search for duplicate issues in the future

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

No branches or pull requests

3 participants