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 8605691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:54:09+00:00 2026-06-12T02:54:09+00:00

I ran across another small stacked bars issue: When filling the plot, flot adds

  • 0

I ran across another small stacked bars issue: When filling the plot, flot adds the legend entries top-down and stacks the bars bottom-up. This way the legend is ordered exactly reverse from the bars.

The flot API allows for sorting the labels in the order they were added, alphabetically, or by providing a custom sorting function. I’ve tried providing a sorting function that always returns -1, so that the original sorting would be reversed but for some reason the sorted option seems not to be evaluated at all when using stacked bars. At least nothing I tried there (ascending, descending, false, function of my own) had any effect on the actual legend.

I’ve put together a test case at http://jsfiddle.net/YvGZu/1/ that illustrates the problem(s).

Edit: After some more testing … could it be that legend-sorting is broken all together?

  • 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-12T02:54:10+00:00Added an answer on June 12, 2026 at 2:54 am

    I coincidentally ran into the same issue as you within a couple of days. After a bit of hairpulling, I realized that the commit to handle legend sorting was quite recent (July 2012) and was not included in the version of jquery.flot.js that I was using.

    From inspecting the flot resource on your Fiddle, it appears the same is true for you. If you update your flot js file to one that includes the sorting algorithm, your issue will likely be resolved, as mine was. (Well, I manually patched, since I had other experimental changes.)

    I’m going to guess that you will next encounter the same roadblock as me, which was that the sorting code as it exists only sorts alphabetically, or with a comparitor that can only examine the label text and colour code. That was not good enough for me — I wanted to assign an arbitrary sort order server side. In order to accomplish this, I added a hidden sort order string to my series labels:

    label: '<a class="hiddenOrder">2</a>foo'
    

    And then style those a blocks in the Flot placeholder to hidden (edit: also need the style to apply to tooltips, which are not contained within the Flot placeholder).

    #flotPlaceholder a.hiddenOrder, 
    #flotTooltip a.hiddenOrder
    {display:none;}
    

    I forked your fiddle and included my ordering technique so you could try it out, but unfortunately it looks like my resource links to GitHub aren’t working within the fiddle. You should be able to get it rolling locally, though.

    Good luck!

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

Sidebar

Related Questions

I ran across a compilation issue today that baffled me. Consider these two container
I ran across an interesting issue today. We have an application that utilizes Zend
I ran across this issue in my application after checking it for memory leaks,
i ran across something i have never seen before. the page has a top
I'm doing some cross platform development, and I ran across another weird problem.. namespace
I ran across an oddity here: https://stackoverflow.com/a/11084038/636656 It appears that assigning to a name
I ran across some code recently at work (recreated to be similar to what
I ran across a very strange line of code in a legacy Perl application.
I ran across this snippet in an internal web site, but I'm having trouble
I ran across a comment that made me wonder: If you use a sharding

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.