Which work nicely and makes the values readable and usable for normal people (in this case 964b)
txt_eth0_rx.text = WSRTCommon_getHumanSize(eth0_rx*8/60, FALSE, TRUE);
- Where getHumanSize is this part:
Code: Select all
string WSRTCommon_getHumanSize(float nr, bool MiB=TRUE, bool BIT=FALSE)
{
int value = 1000;
dyn_string suffixes;
if (!MiB)
{
if (BIT)
{
suffixes = makeDynString("b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb");
}
else
{
suffixes = makeDynString("B", "KB", "MB", "GB", "TB", "PB", "EB");
}
}
else
{
value = 1024;
suffixes= makeDynString("b", "Kib", "Mib", "Gib", "Tib", "bib", "Eib");
if (! BIT)
{
suffixes= makeDynString("B", "KiB", "MiB", "GiB", "TiB", "biB", "EiB");
}
}
// converts disk/file sizes to human readable form
int idx = 1;
while (nr >= value && idx <= dynlen(suffixes))
{
nr /= value;
idx += 1;
}
string val,out;
sprintf(val, "%.2f", nr);
if (nr > 0)
{
out = strrtrim(val,"0.") + " " + suffixes[idx];
}
else
{
out = val + " " + suffixes[idx];
}
return out;
}
//
// base : give base to translate to base 2 means 01-99) base 3 means 001-999
string WSRTCommon_addPendingZeros(uint number, int base)
{
if (base != 2 && base != 3)
{
DebugN(__FILE__ , __FUNCTION__, "Error: base not implemented, should be 2 or 3 ", base);
return "Error";
}
if (base == 2 && number > 99)
{
DebugN(__FILE__ , __FUNCTION__, "Error: number for base 2 should be < 99", number);
return "Error";
}
if (base == 3 && number > 999)
{
DebugN(__FILE__ , __FUNCTION__, "Error: number for base 3 should be < 999", number);
return "Error";
}
string retval = "";
string extra;
if ((number < 10 && base == 2) || (number >= 10 && number < 100 && base == 3 ) )
{
extra = "0";
}
else if (number < 10 && base == 3 )
{
extra = "00";
}
retval = extra + number;
return retval;
}
I don't have any options there when I double click the graph. I can just connect to a datapoint and show that..
Result right now is that I am displaying 14 digit numbers (in this case 15652865389530.00) in a graph, and that makes the scale on the side huge and unusable .