add prep_field method to histogram to allow for custom labeling and grouping of values
This commit is contained in:
parent
cc42012daf
commit
638183b562
@ -195,10 +195,14 @@ class Histogram(StatsFilter):
|
|||||||
self._data = {}
|
self._data = {}
|
||||||
|
|
||||||
def process_field(self, item):
|
def process_field(self, item):
|
||||||
|
item = self.prep_field(item)
|
||||||
if item not in self._data:
|
if item not in self._data:
|
||||||
self._data[item] = 0
|
self._data[item] = 0
|
||||||
self._data[item] += 1
|
self._data[item] += 1
|
||||||
|
|
||||||
|
def prep_field(self, item):
|
||||||
|
return item
|
||||||
|
|
||||||
def value(self):
|
def value(self):
|
||||||
return self._data.copy()
|
return self._data.copy()
|
||||||
|
|
||||||
@ -208,4 +212,3 @@ class Histogram(StatsFilter):
|
|||||||
key_str = str(key).ljust(self.label_length)[:self.label_length]
|
key_str = str(key).ljust(self.label_length)[:self.label_length]
|
||||||
output += "%s %s\n" % (key_str, "*" * self._data[key])
|
output += "%s %s\n" % (key_str, "*" * self._data[key])
|
||||||
return output
|
return output
|
||||||
|
|
Loading…
Reference in New Issue
Block a user