Chart.js: Pie chart - minimum slice size?

Created on 16 Dec 2015  路  8Comments  路  Source: chartjs/Chart.js

Without having to manipulate the data, is there an option to set a minimum slice size for pie charts? I have a dataset with a wide range of values. Some can be in the hundreds, and some can be as small as 1 or 2. You can barely see the slices for these small data points.

Duplicate of #1783

support

Most helpful comment

Did anyone ever find a solution on this. I have slices that are less than 1% and thus not visible on the chart. It would be nice to be able to set a minimum slice size.

All 8 comments

@zhurni-man see my comments on #1783

Hi @etimberg, for me this approach didn't work. Is there another way? See my example bellow. The "Devedor" slice doesn't appear.

screen shot 2018-02-26 at 17 27 27

Did anyone ever find a solution on this. I have slices that are less than 1% and thus not visible on the chart. It would be nice to be able to set a minimum slice size.

Up, still seeking for a solution

Did anyone find a solution about that?

Nope :( I had a go at introducing a min-height/min-width (depending on how you choose to 'bend' your rectangle into a doughnut ;) class/variable to the default doughnut.set JS but it very quickly capitulated into me destroying arc ratios and inner radii so I pussied out. I've just messed with the border-width/color so the 'tiny slice' is made out by the intersecting borders of its neighbouring slices... then used the data-labels plugin to pop a colourful floating bubble-label at the outter-circumference of Mr Mini-Slice... it'll do... I guess :/

I think the slices are invisible because the border width for those slices is bigger than the actual slice. I added this to the pie chart options to circumvent this issue:
if (data.length > 15) { options = { ...options, elements: { arc: { borderWidth: 0, }, }, }; }

Was this page helpful?
0 / 5 - 0 ratings