Setting time window to data on time chart


i have problem with reduction of data amount on chart. My goal is to have always data from last 8 hours [time taken from created column on sp]. List is already limited to last 48h. Problematic is a fact, that i always need last 8h, regardless of day beginning date.
On X axis i need always only last 8h of data.

1 Like

Dear @jacek,
Hmm, you could try something like this in Dashboard > Advanced code to filter out all the items with time difference over 8 hours:

var handlers = {};
handlers.preRender = function(config, logger) {
  for(var i = 0; i < config.series.length; i++){
    var series = config.series[i];
    var new_data ={ 
      var time_diff = Math.abs(new Date() - item.Created);
      return time_diff < 28800000;
    }); = new_data;
  logger.debug('Configuration: ', config);
  return true;
1 Like

Thanks. Works like a charm!


Exacly what i meant. Thank You !!!!