cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
Introduction
This script will sort  the columns of a Columns chart (with break-by) by ascending or descending order. 
 The Script
 Place the following script in the widget's script box
widget.on('processresult',function(se,ev){

   var seriesName = 'Years'; 
   var sortOrder = 'DESC'; // 'ASC' or 'DESC'
   if (sortOrder === 'ASC') { 
      ev.result.series.sort(function(b,a){return a.name.localeCompare(b.name)*(-1); }); 
   } 
   else {
      ev.result.series.sort(function(b,a){return a.name.localeCompare(b.name); });
   }
   var series = ev.result.series;
   $.each(series, function(i, v) {
      series[i].legendIndex = i;
   })
})
Example
Version history
Last update:
‎03-02-2023 09:20 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email community@sisense.com