2014-04-14 15:46:32 -04:00
|
|
|
#include <string>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "graph.h"
|
|
|
|
|
2014-04-19 18:25:53 -04:00
|
|
|
char * getGraphByPercentage(unsigned value, unsigned len) {
|
2014-04-14 15:46:32 -04:00
|
|
|
unsigned step = 0;
|
|
|
|
char * bars = new char[len + 1];
|
|
|
|
|
2015-01-04 11:23:05 -05:00
|
|
|
unsigned barCount = (static_cast<float>(value) / 99.9 * len);
|
2014-04-14 15:46:32 -04:00
|
|
|
|
|
|
|
for(step; step < barCount; step++)
|
|
|
|
bars[step] = '|';
|
|
|
|
for(step; step < len; step++)
|
|
|
|
bars[step] = ' ';
|
|
|
|
bars[len]='\0';
|
|
|
|
|
|
|
|
return bars;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char * getGraphByValue(unsigned value, unsigned max, unsigned len) {
|
|
|
|
unsigned step = 0;
|
|
|
|
char * bars = new char[len + 1];
|
|
|
|
|
2015-01-04 11:23:05 -05:00
|
|
|
unsigned barCount = (static_cast<float>(value / (max - 0.1)) * len);
|
2014-04-14 15:46:32 -04:00
|
|
|
|
|
|
|
for(step; step < barCount; step++)
|
|
|
|
bars[step] = '|';
|
|
|
|
for(step; step < len; step++)
|
|
|
|
bars[step] = ' ';
|
|
|
|
bars[len]='\0';
|
|
|
|
|
|
|
|
return bars;
|
|
|
|
}
|
|
|
|
|