graph's with very big numbers

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
2 posts • Page 1 of 1
genkihenkie
Posts: 10
Joined: Thu Oct 27, 2016 12:24 pm

graph's with very big numbers

Post by genkihenkie » Wed Jul 10, 2019 12:11 pm

So we are getting these huge numbers, for the data throughput.. and for the GUI text we changed them to readable numbers.
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;
}
But how do I do it in a trend graph? I got a request to show the last few hours of the throughput in a graph on top of the page.
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 .
Last edited by gschijndel on Thu Jul 11, 2019 1:19 pm, edited 1 time in total.
Reason: Placed code tags

gschijndel
Posts: 97
Joined: Tue Jan 15, 2019 2:12 pm

Re: graph's with very big numbers

Post by gschijndel » Thu Jul 11, 2019 1:37 pm

The trend has a feature to map a text to a value (curveValuesTexts), but it only changes the shown value in the legend and ruler window. So it does not help with the scale(s).
It is also possible to fill the trend with own values, so it is possible to do self the connect, fill the trend with readable values and provide some suffix indication outside the trend.

Post Reply
2 posts • Page 1 of 1