byronwall / bUTL

Excel add-in with helpers for charting, formatting, and general pain points
http://byroni.us/bUTL
MIT License
16 stars 3 forks source link

Pie chart fixing? #41

Closed RaymondWise closed 8 years ago

RaymondWise commented 9 years ago

I'm no good working with charts and looked through the code in bUTL in reference to this question on SU - http://superuser.com/questions/995587/programmatically-rotate-a-pie-chart-to-fix-the-labels

Thought you might have a solution.

byronwall commented 9 years ago

I looked at this briefly but could not find a clean way to get the size and position of the pie slice. Excel seems to do some rearranging of the slices depending on their relative sizes so relying on Series order and the value of the data point is not reliable. The data point has a Top/Left and Height/Width, but it looks like that applies to bounding box of the slice? If that information is available, the part about rotating the pie chart would be doable. It's simple enough to calculate a "density" of small slices which could then be oriented into a corner. The second part about optimal positioning of labels is much more difficult. There are some heavy duty algorithms out there to position labels while drawing other types of diagrams, but I think in general those are all optimized to the application at hand. I doubt there's a simple approach that will best the "Best Fit" option provided by Excel.

Ultimately, I have typically avoided pie charts so the bUTL code is thin on that front. I know there is something of a wider debate there. I have always found a stacked bar/column chart to be sufficient when comparing relative amounts.

On Thu, Nov 5, 2015 at 10:52 AM, Ray Wise notifications@github.com wrote:

I'm no good working with charts and looked through the code in bUTL in reference to this question on SU - http://superuser.com/questions/995587/programmatically-rotate-a-pie-chart-to-fix-the-labels

Thought you might have a solution.

— Reply to this email directly or view it on GitHub https://github.com/byronwall/bUTL/issues/41.