- for bucket in sorted(self.buckets, key=lambda x : x[0]):
- pop = self.buckets[bucket]
+ max_label_width = None
+ lowest_start = None
+ highest_end = None
+ for bucket in sorted(self.buckets, key=lambda x: x[0]):
+ start = bucket[0]
+ if lowest_start is None:
+ lowest_start = start
+ end = bucket[1]
+ if highest_end is None or end > highest_end:
+ highest_end = end
+ if label_formatter is None:
+ if type(start) == int and type(end) == int:
+ label_formatter = '%d'
+ elif type(start) == float and type(end) == float:
+ label_formatter = '%.2f'
+ else:
+ label_formatter = '%s'
+ label = f'[{label_formatter}..{label_formatter}): ' % (start, end)
+ label_width = len(label)
+ if max_label_width is None or label_width > max_label_width:
+ max_label_width = label_width
+ if start == last_bucket_start:
+ break
+ sigma_label = f'[{label_formatter}..{label_formatter}): ' % (
+ lowest_start,
+ highest_end,
+ )
+ if len(sigma_label) > max_label_width:
+ max_label_width = len(sigma_label)
+ bar_width = width - (max_label_width + 16)
+
+ for bucket in sorted(self.buckets, key=lambda x: x[0]):