Is it possible to order break-bys by value?

Comments

4 comments

  • Avatar
    Yoni Lerner

    Right now there is no script that does this.

    You will need to create a new script taking different elements from these script and combining them together.

    If this is essential for your business need you can open a ticket regarding this to the support team.

    0
    Comment actions Permalink
  • Avatar
    Aware Manager

    Nick,

    Did you end up having a script created by the support team and if so, could you share it here?

    0
    Comment actions Permalink
  • Avatar
    Tim Coppola

    No, I never got a response.

    1
    Comment actions Permalink
  • Avatar
    Nick Burleigh (Edited )

    Hi Joe & Tim,

    I worked with someone from support on the following script. It turns out that you can't really order the segments in each column from greatest to least, because every column needs to have the exact same order. (Feel free to correct me on that, anyone who knows better!) What we figured out was a way to select a "reference column," order that column from greatest to least, and then use that order for all the columns. I actually found this to be more visually appealing anyway, since if each column were ordered by value, the segments might "jump around" in position from column to column.

    Here's the script:

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

    var series = ev.result.series;
    var colIndx = series[0].data.length - 1; // This sets the reference column. "series[0].data.length - 1" would be the farthest-right column. Set colIndex to 0 for farthest-left column.

    series.sort(sortFunction);

    function sortFunction(a, b) {
    if (a.data[colIndx].y === b.data[colIndx].y) {
    return 0;
    }
    else {
    return (a.data[colIndx].y < b.data[colIndx].y) ? -1 : 1;
    }
    }
    });
    1
    Comment actions Permalink

Please sign in to leave a comment.