[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Drop duplicate axis_offset calculation



commit 680d5f48fa1f76c043672eb475bee8554254834b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Apr 18 11:40:28 2018 -0700

    Drop duplicate axis_offset calculation
    
    Minor innocuous simplification. We got the width of our y-axis labels twice -
    might as well do it once.
---
 nyx/panel/graph.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/nyx/panel/graph.py b/nyx/panel/graph.py
index 79b50fa..dc71107 100644
--- a/nyx/panel/graph.py
+++ b/nyx/panel/graph.py
@@ -616,13 +616,14 @@ def _draw_subgraph(subwindow, data, x, width, height, bounds_type, interval, col
 
   x_axis_labels = _x_axis_labels(interval, columns)
   y_axis_labels = _y_axis_labels(height, data, min_bound, max_bound)
-  columns = max(columns, width - max([len(label) for label in y_axis_labels.values()]) - 2)
-  axis_offset = max([len(label) for label in y_axis_labels.values()])
+
+  x_axis_offset = max([len(label) for label in y_axis_labels.values()])
+  columns = max(columns, width - x_axis_offset - 2)
 
   subwindow.addstr(x, 1, data.header(width), color, BOLD)
 
   for x_offset, label in x_axis_labels.items():
-    subwindow.addstr(x + x_offset + axis_offset, height, label, color)
+    subwindow.addstr(x + x_offset + x_axis_offset, height, label, color)
 
   for y, label in y_axis_labels.items():
     subwindow.addstr(x, y, label, color)
@@ -630,7 +631,7 @@ def _draw_subgraph(subwindow, data, x, width, height, bounds_type, interval, col
   for col in range(columns):
     column_count = int(data.values[interval][col]) - min_bound
     column_height = int(min(height - 2, (height - 2) * column_count / (max(1, max_bound) - min_bound)))
-    subwindow.vline(x + col + axis_offset + 1, height - column_height, column_height, color, HIGHLIGHT, char = fill_char)
+    subwindow.vline(x + col + x_axis_offset + 1, height - column_height, column_height, color, HIGHLIGHT, char = fill_char)
 
 
 def _x_axis_labels(interval, columns):

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits