diff options
-rwxr-xr-x | rare/interrupts-graph.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rare/interrupts-graph.py b/rare/interrupts-graph.py index 76006cd..1a26cce 100755 --- a/rare/interrupts-graph.py +++ b/rare/interrupts-graph.py @@ -234,10 +234,11 @@ def refresh_data(): return updated smooth = {} +last_min_x = 0 @synchronized(data_lock) def update(): """Reads new data and updates the line values.""" - global update_legend + global update_legend, last_min_x # Update lines for name in names: ys = yvalues[name] @@ -298,7 +299,13 @@ def update(): # The first XRANGE items fit in the screen min_x = max(start_time - XRANGE, 0) - plt.xlim(min_x, min_x + XRANGE) + cur_min_x, _ = plt.xlim() + # If the current range is equal or further than the previously recorded + # range, consider it sticky and update the xlim with the new range. + if cur_min_x >= last_min_x: + last_min_x = min_x + if cur_min_x <= min_x: + plt.xlim(min_x, min_x + XRANGE) def do_draw(): """Actually draw the graph, updating the legend if necessary.""" |