ENH make axis text more compact

This commit is contained in:
Nathan Dwarshuis 2021-07-13 23:01:28 -04:00
parent 6218bbd73a
commit 3efe2d8b6b
2 changed files with 4 additions and 11 deletions

View File

@ -4,14 +4,14 @@ local Util = require 'Util'
local Common = require 'Common' local Common = require 'Common'
local __string_gmatch = string.gmatch local __string_gmatch = string.gmatch
local __math_floor = math.floor
local _PLOT_SEC_BREAK_ = 20 local _PLOT_SEC_BREAK_ = 20
local _PLOT_HEIGHT_ = 56 local _PLOT_HEIGHT_ = 56
local network_label_function = function(bits) local network_label_function = function(bits)
local new_unit, new_value = Util.convert_data_val(bits) local new_unit, new_value = Util.convert_data_val(bits)
local precision = new_value < 10 and 1 or 0 return __math_floor(new_value)..' '..new_unit..'b/s'
return Util.round_to_string(new_value, precision)..' '..new_unit..'b/s'
end end
local value_format_function = function(bits) local value_format_function = function(bits)

View File

@ -5,6 +5,7 @@ local Common = require 'Common'
local __tonumber = tonumber local __tonumber = tonumber
local __string_match = string.match local __string_match = string.match
local __math_floor = math.floor
local _PLOT_SEC_BREAK_ = 20 local _PLOT_SEC_BREAK_ = 20
local _PLOT_HEIGHT_ = 56 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 local delta_bytes = byte_cnt - stat.prev_byte_cnt
stat.prev_byte_cnt = byte_cnt stat.prev_byte_cnt = byte_cnt
-- local text_value = '0.00 B/s'
local plot_value = 0 local plot_value = 0
if delta_bytes > 0 then if delta_bytes > 0 then
local bps = delta_bytes * update_frequency 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 plot_value = bps
end end
-- Common.annotated_scale_plot_set(stat, cr, text_value, plot_value)
Common.annotated_scale_plot_set(stat, cr, plot_value) Common.annotated_scale_plot_set(stat, cr, plot_value)
end end
local io_label_function = function(bytes) local io_label_function = function(bytes)
local new_unit, new_value = Util.convert_data_val(bytes) local new_unit, new_value = Util.convert_data_val(bytes)
return __math_floor(new_value)..' '..new_unit..'B/s'
local precision = 0
if new_value < 10 then precision = 1 end
return Util.round_to_string(new_value, precision)..' '..new_unit..'B/s'
end end
local format_value_function = function(bps) local format_value_function = function(bps)