var updateHorizontalBarChart = function()

in source/web_site/js/dash.js [311:332]


  var updateHorizontalBarChart = function(data, noOfTopItems, chartName, queryTime, labelFunc=identity) {
    var items = data.Items;
    var ipCountMap = {};
    
    // Merge the counts of each DDB item into a single map.
    for (var i=0; i<items.length; i++) {
      var entryMap = JSON.parse(items[i].Data);
      var mySet = new Set(Object.keys(entryMap));
      for (let key1 of mySet) ipCountMap[key1] = entryMap[key1];
    }

    if (items.length > 0) {
      queryTime = items[items.length-1].EventTime;
      
      var topIps = Object.keys(ipCountMap).sort(function(a,b) { return ipCountMap[b] - ipCountMap[a]}).slice(0,noOfTopItems);

      var topIpCounts = topIps.map(function(ip) {return ipCountMap[ip]; })
      topIps = topIps.map(labelFunc);
      addData(chartName,topIps,topIpCounts);
    }
    return queryTime;
  };