PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.53k stars 9.01k forks source link

PieChart not drawing correctly (v2.2.3) #1528

Closed mavoi closed 8 years ago

mavoi commented 8 years ago

I just upgraded to 2.2.3 and now my PieChartView is doing strange things:

bildschirmfoto 2016-02-29 um 22 20 50 bildschirmfoto 2016-02-29 um 22 21 13 bildschirmfoto 2016-02-29 um 22 21 31

Afaik this wasn't happening in 2.2.2 or I have never recognized it. 2 Entrys, one set to 99 and the other set to 1. This is my chart setup:

percentageChart.usePercentValuesEnabled = true percentageChart.holeRadiusPercent = 0.9 percentageChart.transparentCircleRadiusPercent = 0.45 percentageChart.rotationWithTwoFingers = false percentageChart.drawCenterTextEnabled = true percentageChart.descriptionText = "" percentageChart.noDataText = "" percentageChart.noDataTextDescription = "" percentageChart.centerText = "" percentageChart.drawSliceTextEnabled = false percentageChart.rotationEnabled = false percentageChart.legend.enabled = false percentageChart.highlightPerTapEnabled = false

Did I miss anything?

PhilJay commented 8 years ago

This is ios, do you know what's going on @danielgindi ?

To mee it looks like some kind of offset issue or too high selection shift?

mavoi commented 8 years ago

Holy **\ you are right. I'm sorry this accidentally got postd here. I am using both librarys, sorry. Should I delete it here and repost it in ios-charts issue tracker?

PhilJay commented 8 years ago

It's fine, just leave it here :-)

PhilJay commented 8 years ago

I can confirm 2 issues:

  1. If two entries (values 99 and 1) are used in the PieChart and the hole is disabled, it still appears as this (a middle sized hole): screenshot_2016-02-29-23-42-53
  2. If only one entry is in the PieChart, it does not appear at all (and sometimes flickers): screenshot_2016-02-29-23-44-56
mavoi commented 8 years ago

The issue seems to be linked to sliceSpace. When set to 0 the PieChart seems to act normal (in my example above the slicespace was set to 3).

danielgindi commented 8 years ago

Issue 1: I'm looking into this!

For issue 2: This shouldn't happen as I made a fix for that - which was due to Android modding the arc angle (drawing arc from 0 to 0), So I used a circle instead.

danielgindi commented 8 years ago

Okay so the hole you see is definitely because of slice spacing. We are now calculating what is the minimum inner radius we need to keep the slice spacing evenly distributed. If the hole was not present - the spacing was not even because if you draw the line into the center point - the angle of the spacing changes.

But I think there's a way around that - I'm trying to improve the formula :-)

danielgindi commented 8 years ago

Update: I've managed to fixed the case where hole is disabled. Still there's a bug with holes enabled. I'll push the code when I'm finished with this

mavoi commented 8 years ago

Awesome! Thanks :-)

danielgindi commented 8 years ago

Okay it seems like the math was okay - just the logic was a bit flawed. Didn't think of all the different combinations of cases...

danielgindi commented 8 years ago

Phil do you want to see if you are still experiencing the flicker with 1 or 2 pie slices?

PhilJay commented 8 years ago

Everything seems fixed except one: If I only add one entry with (ofc) 100%, it disappears when the hole is activated. If there is one entry and no hole, it draws just fine.

danielgindi commented 8 years ago

Basically in this case it creates a path with a circle (CCW) inside a circle (CW) - and it did work for me. I don't know why you are still seeing this...

Well, I'm going to sleep, will look at it tomorrow :-)

RudolfHladik commented 8 years ago

is there any workaround in 2. issue?

danielgindi commented 8 years ago

@RudolfHladik The issues are fixed. You can add the jar release to your project, or wait until there's a gradle release