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

ChartEasingOption causes entire background to be filled with color #826

Closed
ClockWise89 opened this issue Mar 10, 2016 · 10 comments
Closed

Comments

@ClockWise89
Copy link

I've been using a few different animations with my PieChartView, and for some values during the animation the entire PieChartView gets filled with the color set for the DataSet. I used version 2.1.4 up until today and decided to upgrade since there are features I'd like to use in 2.2.3. But now my animations are causing really weird behaviour. For some data it animates as expected, but for other data (I can't seem to find a pattern) it also animates correctly, but fills and unfills the background of the ChartView. Imagine taking the fill bucket in Photoshop and clicking in an empty square, that's what's happening visually.

If I don't animate everything works fine. Some ChartEasingOption is more messed up than others, but I really need to get this animation to work. There has been some changes to the way you structure data and colors in 2.2.3 compared to 2.1.4, but it doesn't feel like I've done anything wrong.

I call my functions in this order:

private func setupPieChart() {

        pieChartView.delegate = self
        pieChartView.holeColor = nil
        pieChartView.holeRadiusPercent = 0.90
        pieChartView.transparentCircleRadiusPercent = 0.61

        pieChartView.userInteractionEnabled = false
        pieChartView.drawSliceTextEnabled = false
        pieChartView.drawHoleEnabled = true
        pieChartView.descriptionText = ""
        pieChartView.legend.enabled = false
    }
private func setPieChartData() {

        var dataEntries: [ChartDataEntry] = []
        var dataPoints: [String] = []

        // Append data


            for var i = 0; i < adjustedExpenseHistory.count; i++ {
                let dataEntry = ChartDataEntry(value: adjustedExpenseHistory[i].amount, xIndex: i)
                dataEntries.append(dataEntry)
                dataPoints.append(adjustedExpenseHistory[i].category.rawValue)
            }


        let pieChartDataSet = PieChartDataSet(yVals: dataEntries, label: nil)
        let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
        pieChartView.data = pieChartData

        pieChartDataSet.colors = [getColor()]
        pieChartDataSet.drawValuesEnabled = false
        pieChartDataSet.sliceSpace = 4.0
    }

private func animate() {
        pieChartView.animate(xAxisDuration: 1.5, yAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)
    }

Edit:
I reverted back to 2.1.4, and it works fine with the same data and same code.

@danielgindi
Copy link
Collaborator

There were a few enhancements to pie charts in 2.1.3 - which caused a rendering bug in some cases. That was fixed - but not released yet. Could you try with the code from master?

@ClockWise89
Copy link
Author

@danielgindi I tried using the master branch, but it didn't work. Unless I used it wrong. I'm a bit new to CocoaPods but my podfile looks like this (and didn't cause any errors):

pod 'Charts', :git => 'https://github.com/danielgindi/ios-charts.git', :branch => 'master'

I also tried without

, :branch => 'master'

@ClockWise89
Copy link
Author

Been trying to figure out why this is happening for a few days now, but I can't seem to find the issue. Anyone else experiencing the same issue? Right now it looks like I'll have to fork the 2.1.4 and add some functionality from 2.2.3 in my fork instead...which is not preferred since this will most likely cause a lot of merging conflicts once I merge with future versions.

@danielgindi
Copy link
Collaborator

I'm not sure about what the Pod configuration should be- But haveyou tried downloading the zip from Github, and running the demo?

@pmairoldi
Copy link
Collaborator

The podfile syntax looks right have you tried using pod update

@ClockWise89
Copy link
Author

I haven't tried running the demo, but since this issue occurs depending on the data in the pie chart it might not happen in the demo, I suppose. I'm 98 % certain that I installed the pod correctly, but I haven't run pod update. Don't think it should matter though.

Will try the demo and see if I can get it to occur there as well so I have a sample I could hand you.

@ClockWise89
Copy link
Author

So I did try to update pod like @petester42 suggestion, but it didn't help. The pods are updated as expected of course, but the error I'm having still occurs. I also spent the last hour or so trying to reproduce in the issue in the iOS-Charts Demo, but to no avail. But I'm pretty sure something has changed since I use the exact same code for 2.1.4 and 2.2.3, and I don't have this issue in 2.1.4 but in 2.2.3 :<

Guess I'll continue to try an reproduce the error in the Demo project tomorrow.

@ClockWise89
Copy link
Author

So I managed to reproduce my issue in a sample project. Could someone please take a look at it? It works like a charm if the animation is not used, but it doesn't seem to occur on all different animations, but I'm not sure.

Sample project

Update: @danielgindi I've localised some useful information. Whenever I have more than 1 data entry, and where one entry is larger than 324.8 degrees the rendering flips out. I tried having only 1 data entry and it worked fine, having several data entries where all are below 324.9 degrees also works fine, but as soon as any of them gets 324.9 or above it starts to cause rendering issues. The issues are also related to the degrees themselves, a pie occupying 324.9 causes less dramatic issues than a pie occupying 330 degrees.

Since I've located which data messes this up I'm going to head into the Demo project and see if I can reproduce it there as well. Cheers!

Update #2:

I managed to get the issue in the Demo project as well. It seems to occur only for the [_chartView animateWithXAxisDuration:1.5 yAxisDuration:1.5 easingOption:ChartEasingOptionEaseOutBack]; animation. I had 2 pies, occupying 20 and 340 degrees of the pie chart.

@danielgindi
Copy link
Collaborator

Is this still happening to you with 2.2.4?

@ClockWise89
Copy link
Author

@danielgindi I tried quickly with 2.2.4 and the issue seems to be gone. I'll let you know if I encounter it again, but at first glance it seems to be fixed. Cheers!

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

3 participants