Manually Order a Column Chart

Comments

18 comments

  • Avatar
    Sarah

    Tommy, this is great, so helpful, thank you! It seems like this works great for a column chart on the top level category. I'd like to sort the second level of category as well for a clustered column chart. Any ideas about how to modify the script so it'll work on a category that's nested under another category?

    Thanks so much,

    Sarah

    1
    Comment actions Permalink
  • Avatar
    Benjamin Spain (Edited )

    For just category sorting, I found it simpler to use the 'queryend' event, instead of the 'processresult' event, and simply apply a sort function to the ev.rawResult.values collection.

    1
    Comment actions Permalink
  • Avatar
    Lee Hermon

    Thank you Ben! Feel free to create an article about this if you like :-)

    0
    Comment actions Permalink
  • Avatar
    Jon Wrye

    Anyone else have trouble with this working inconsistently? I'm using this script with a break by of about 45 "breaks." Occasionally, when data in the dashboard is filtered and the break by categories change, they are completely out of order. Refreshing the browser puts them in order, but it's a little odd. Like the Javascript isn't always executed. Running in the latest version of Chrome. Anyone else noticed this?

    2
    Comment actions Permalink
  • Avatar
    Omer (Edited )

    Hi Jon,

    It seems you're experiencing a specific issue.

    In order for us to further investigate this, could you please submit a ticket with the whole details? (just go to "Submit a request" in the upper right corner, near the profile name)

    Thanks,

    Omer

     

    0
    Comment actions Permalink
  • Avatar
    Nick Burleigh

    Hey guys,

    Good stuff here! I'm trying to automatically sort each column by largest segment to smallest segment, in a "break by" scenario. Is there any way to adjust this script to order by segment size, rather than a fixed ordering? Can't find the answer to this specific question anywhere in the forums. Thanks so much!

    0
    Comment actions Permalink
  • Avatar
    Monica Moore

    I am having the same issue as Jon, so it may not be just an issue specific to him. The ordering works in theory, but when I change the dashboard filters, previous values *stick* in this widget until I refresh, and many times the VALUES are still out of order even though the labels themselves are correctly ordered. 

    2
    Comment actions Permalink
  • Avatar
    Shashank Mohan (Edited )

    Hey everyone, 

    This is a great trick but doesn't seem to be working with the latest release if I just want to sort by 'break by'. Anyone facing the same issue?

    Shashank

     

    -- Never mind - it is working, thanks.

    -- Actually I am facing the same stickiness issue.

    0
    Comment actions Permalink
  • Avatar
    Ian Emmons

    This is cool. Unfortunately it stops working if any of the categories has no results. So in the example above, if you filtered by store or something like that and the store you selected sold no produce, the whole chart just shows blank.

    Which is a bummer.

    0
    Comment actions Permalink
  • Avatar
    Tyler Shaw

    Is there a way to make this work for line charts? Thanks!

    1
    Comment actions Permalink
  • Avatar
    Nick Atkinson

    Would be great to get this manual order by solution available for a pie chart. Anyone know if that's available anywhere? I can't see it but it would be really helpful for me.

    Noob question: What programming language is the widget script written in? Is it Python?

    Thanks all.

    0
    Comment actions Permalink
  • Avatar
    Tim Coppola

    Our widgets with this script that were built and implemented prior to the 7.0.XXX release of Sisense still work as expected.  We always left the category field blank (1 text category field) and were sorting each individual column's breakby.

    It is only when trying to apply the script to new widgets that it no longer works.  It appears adding a dashboard filter has it work temporarily. 

    Has anyone been able to resolve this with the new releases?  Sisense claims they can't offer support because it is not part of their certified add-ons; seems like there should be a built in solution for this.

    0
    Comment actions Permalink
  • Avatar
    Alina Lotman

    Hi,

    I am using this to sort my break by categories but is there a way to reverse the order of the categories in the legend? So the bottom category is in the left and the top category is on the right? 

    Thanks!

    1
    Comment actions Permalink
  • Avatar
    Tim Coppola

    @Alina Lotman

     

    Forget which post I found this in, but we throw this after the last } in the above script and it sorts the legend as you described:

     

    widget.on('processresult',function(se,ev){

    var series = ev.result.series;
    var numberOfSeries = ev.result.series.length;
    for(var i=0;i < numberOfSeries;i++){
    series[i].legendIndex = numberOfSeries - i;
    }
    })

    1
    Comment actions Permalink
  • Avatar
    Alina Lotman

    Thank you Tim Coppola! works like a charm!

    0
    Comment actions Permalink
  • Avatar
    David Oyler

    Is this still working in 7.2?

    0
    Comment actions Permalink
  • Avatar
    Janet Erdman

    It worked for the categories but it did not change the order of the Break By. Is there something else that needs to be done from the above script to change the order for both the category and break by?

    0
    Comment actions Permalink
  • Avatar
    Elliott Herz

    Hey Janet,


    Checkout this plugin instead of using scripts, its a lot easier to use/maintain.

    https://support.sisense.com/hc/en-us/community/posts/360020822513-Custom-Bar-Column-Chart-Plugin-Show-Totals-Sort-Categories-Sort-Breakbys-

    Best,

    Elliott

    0
    Comment actions Permalink

Please sign in to leave a comment.