How to sort values by decreasing order

Hi
I am doing a vertical chart bar and I would like to

  • sort by decreasing order
  • display only the top 10 largest values on the graph

How do I do that?

Thanks

Hi,

Go to Dashboard -> Advanced and paste the following code into the preRender function:

config.series[0].data.sort(function(a, b) { return b.Revenue - a.Revenue; }); config.series[0].data = config.series[0].data.slice(0,10);

Where Revenue is the internal name of the field you want to sort your columns by.

Hello

Thanks very much. I tried a couple of times but not entirely sure where to copy the text. Sorry… is the below correct?. My values to sort are “Gross value”

var handlers = {};
handlers.preRender = function (config.series[0].data.sort(function(a, b) {
return b.gross value - a.gross value;
});
config.series[0].data = config.series[0].data.slice(0,10);, logger) {
logger.debug('Configuration: ', config);
return true;
}

Thanks

Sonia

That would be:

var handlers = {}; handlers.preRender = function(config, logger) { logger.debug('Configuration: ', config); config.series[0].data.sort(function(a, b) { return b.Revenue - a.Revenue; }); config.series[0].data = config.series[0].data.slice(0,10); return true; }