Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8167411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:11:04+00:00 2026-06-06T20:11:04+00:00

I use jquery flot for my pie charts and I have a problem with

  • 0

I use jquery flot for my pie charts and I have a problem with overlapping
labels when the pie chart pieces are very small. Is there a good
solution for that?

My pie chart:

series: { 
                pie: { 
                    show: true, 
                    radius: 1, 
                    label: { 
                        show: true, 
                        radius: 5/8, 
                        formatter: function(label, series){ 
                            return '<div style="font-size:12pt;text-  align:center;padding:2px;color:black;margin-left:-80%;margin-  top:-20%;">'+label+'<br/>'+Math.round(series.percent)+'%</div>'; 
                        }, 
                        background: { opacity: 0.5 } 
                    } 
                } 
            }, 
            legend: { 
                show: false 
            }

Thanks, Arshavski Alexander.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:11:05+00:00Added an answer on June 6, 2026 at 8:11 pm

    A solution from Flot’s Google code issues by Marshall Leggett(link):

    I’ve found that it seems common for pie labels to overlap in smaller
    pie charts making them unreadable, particularly if several slices have
    small percentage values. This is with the jquery.flot.pie plugin.
    Please see attached images. I’ve worked around this with the addition
    of an anti-collision routine in the label rendering code. I’m
    attaching a copy of the revised plugin as well. See lines 472-501,
    particularly the new functions getPositions() and comparePositions().
    This is based in part on Šime Vidas’ DOM-element collision detection
    code. Something like this might be a nice addition to the pie
    library.

    pie labels overlapping
    pie labels overlapping fixed

    long story short:

    1. In jquery.flot.pie.js and after the line 463 that contains:

      label.css('left', labelLeft);

    add the following code:

    // check to make sure that the label doesn't overlap one of the other labels
    var label_pos = getPositions(label);
    for(var j=0; j<labels.length; j++)
    {
    var tmpPos = getPositions(labels[j]);
    var horizontalMatch = comparePositions(label_pos[0], tmpPos[0]);
    var verticalMatch = comparePositions(label_pos[1], tmpPos[1]);                  
    var match = horizontalMatch && verticalMatch;                           
    if(match)
    {
        var newTop = tmpPos[1][0] - (label.height() +1 );
        label.css('top', newTop);
        labelTop = newTop;
    }       
    }
    
    function getPositions(box) {
            var $box = $(box);
            var pos = $box.position();
            var width = $box.width();
            var height = $box.height();
            return [ [ pos.left, pos.left + width ], [ pos.top, pos.top + height ] ];
    }
    
    function comparePositions(p1, p2) {
            var x1 = p1[0] < p2[0] ? p1 : p2;
            var x2 = p1[0] < p2[0] ? p2 : p1;
            return x1[1] > x2[0] || x1[0] === x2[0] ? true : false;
    }
    labels.push(label);
    
    1. Add the following to drawLabels() and you are done:

      var labels = [];

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two pages that use the flot jquery plugin, and they both work
I'm trying to use the jquery flot graphing plugin with asp.net mvc. I'm trying
I use jquery pagination plugin for paging... If there is one pagination plugin there
I'm using the Flot graphing library jQuery plugin and I haven't found a good
I use jQuery form validation plugin . I have got a webpage with save
I used to work with flot but it doesn't support pie charts so I'm
I use Jquery tools rangeinput . For example I have: <input id=testId title=test class=range
I use jquery masonry + infinite scroll. I would have the preloading effect with
So basically, I have a test graph in JQuery-Flot, and instead of the normal
I use jquery to post data to mysql. **In settings.php i have this short

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.