question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pie chart radial labels overlap

See original GitHub issue

To Reproduce Please see: https://codesandbox.io/s/nivopie-total-inside-donut-434-forked-eq1yi?file=/src/index.js image

Expected behavior Radial labels should not overlap each other

Any way to make them not overlap? Using the radialLabelsSkipAngle is not an option they should be present at all times. All other options does not resolve the issue.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:14

github_iconTop GitHub Comments

7reactions
aaronovz1commented, Jun 15, 2022

buuuuump, can we get a release with this fix?

3reactions
davidkim10commented, Mar 18, 2022

I wish I contributed my solution when I wrote it 2 years ago but I solved this issue by adjusting the computeRadialLabels function. By adjusting this function and using the padAngle prop I was able to fix the overlap.

Screen Shot 2020-05-29 at 5 09 11 PM Screen Shot 2020-05-29 at 5 09 47 PM Screen Shot 2020-05-29 at 5 11 28 PM

Im trying to find the exact fix from a project I worked on 2 years ago but honestly cant recall my thought process at the time but i adjusted nivo-pie.esm.js. From the screenshot below I adjusted radial label offset and the radial length offset (position A and B).

Screen Shot 2022-03-15 at 12 15 52 PM

// For the function computeRadialLabels I added the following:
const { angleDeg } = arc;
const absSin = Math.abs(Math.sin(angle));
const offsetReducer = angleDeg < 10 ? 1 : 2;
const baseOffset = radiansToDegrees(Math.asin(absSin)) / offsetReducer;
const linkDiagonalLengthOffset = baseOffset * absSin;

// radial label offset
var positionA = positionFromAngle(angle, radius);

// Position B = radial length (positionB.x, positionB.y)
var positionB = positionFromAngle(
  angle,
  radius + linkOffset + linkDiagonalLengthOffset + linkDiagonalLength
);

(nivo/pie v 0.61.1)

Related Issues: https://github.com/plouc/nivo/issues/143

View Updated nivo-pie.esm.js file

Hope this helps in anyway to those experiencing the same issue. If anyone has the bandwidth to properly commit this fix please do. Maybe @plouc , @wyze , or anyone else who maintains the package can take a look at the approach and refactor a better solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How to avoid overlapping of labels & autopct in a ...
Is it possible to show the labels "Jan", "Feb", "Mar", etc. and the percentages, either: without overlapping, or; using an arrow mark ?...
Read more >
Set Up a Pie Chart with no Overlapping Labels in the Graph
Solution. By default, the layout engine will try to arrange the data labels so they do not overlap. When the bounds of two...
Read more >
Pie Chart Labels Overlap Python
The labels of my created pie chart overlaps. 1 The radial distance at which the pie labels are drawn. Python matplotlib Pie Chart....
Read more >
R Pie Chart Labels Overlap
R Pie Chart Labels Overlap1 day ago · These are the list of libraries we will be using in this short session: ggplot2...
Read more >
Pie Chart Labels Overlap Python
Pie Chart Labels Overlap PythonLet's see the below example for better ... Note that margin object does not take radial labels into ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found