From 3efe2d8b6b4158f10def29c22fd9e6a967a39bb5 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Tue, 13 Jul 2021 23:01:28 -0400 Subject: [PATCH] ENH make axis text more compact --- drawing/Network.lua | 4 ++-- drawing/ReadWrite.lua | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drawing/Network.lua b/drawing/Network.lua index 9a3fcb6..e813947 100644 --- a/drawing/Network.lua +++ b/drawing/Network.lua @@ -4,14 +4,14 @@ local Util = require 'Util' local Common = require 'Common' local __string_gmatch = string.gmatch +local __math_floor = math.floor local _PLOT_SEC_BREAK_ = 20 local _PLOT_HEIGHT_ = 56 local network_label_function = function(bits) local new_unit, new_value = Util.convert_data_val(bits) - local precision = new_value < 10 and 1 or 0 - return Util.round_to_string(new_value, precision)..' '..new_unit..'b/s' + return __math_floor(new_value)..' '..new_unit..'b/s' end local value_format_function = function(bits) diff --git a/drawing/ReadWrite.lua b/drawing/ReadWrite.lua index f2f3ba5..a3fed89 100644 --- a/drawing/ReadWrite.lua +++ b/drawing/ReadWrite.lua @@ -5,6 +5,7 @@ local Common = require 'Common' local __tonumber = tonumber local __string_match = string.match +local __math_floor = math.floor local _PLOT_SEC_BREAK_ = 20 local _PLOT_HEIGHT_ = 56 @@ -24,25 +25,17 @@ local update_stat = function(cr, stat, byte_cnt, update_frequency) local delta_bytes = byte_cnt - stat.prev_byte_cnt stat.prev_byte_cnt = byte_cnt - -- local text_value = '0.00 B/s' local plot_value = 0 if delta_bytes > 0 then local bps = delta_bytes * update_frequency - -- local unit, value = Util.convert_data_val(bps) - -- text_value = Util.precision_round_to_string(value, 3)..' '..unit..'B/s' plot_value = bps end - -- Common.annotated_scale_plot_set(stat, cr, text_value, plot_value) Common.annotated_scale_plot_set(stat, cr, plot_value) end local io_label_function = function(bytes) local new_unit, new_value = Util.convert_data_val(bytes) - - local precision = 0 - if new_value < 10 then precision = 1 end - - return Util.round_to_string(new_value, precision)..' '..new_unit..'B/s' + return __math_floor(new_value)..' '..new_unit..'B/s' end local format_value_function = function(bps)