0
대역폭 사용에 대한 히스토그램을 인쇄하는 ncurses 프로그램이 있습니다. 그래프를 최소 0 대신 항상 0으로 스케일링하고 싶습니다. (따라서 그래프는 0이 아닌 최소 속도로 시작됩니다.) 이 그래프의 최소 크기를 조절 할 수 있도록ncurses 히스토그램 프로그램의 그래프를 최소로 조정하는 방법
if (value/max * lines < currentline)
addch('*');
else
addch(' ');
은 어떻게 계산을 변경할 수 있습니다
그래프
은 기본적으로 다음과 같이 인쇄됩니다? 당신은max
뿐만 아니라 모든 값의
min
필요
void printgraphw(WINDOW *win, char *name,
unsigned long *array, unsigned long max, bool siunits,
int lines, int cols, int color) {
int y, x;
werase(win);
box(win, 0, 0);
mvwvline(win, 0, 1, '-', lines-1);
if (name)
mvwprintw(win, 0, cols - 5 - strlen(name), "[ %s ]",name);
mvwprintw(win, 0, 1, "[ %s/s ]", bytestostr(max, siunits));
mvwprintw(win, lines-1, 1, "[ %s/s ]", bytestostr(0.0, siunits));
wattron(win, color);
for (y = 0; y < (lines - 2); y++) {
for (x = 0; x < (cols - 3); x++) {
if (array[x] && max) {
if (lines - 3 - ((double) array[x]/max * lines) < y)
mvwaddch(win, y + 1, x + 2, '*');
}
}
}
wattroff(win, color);
wnoutrefresh(win);
}
감사합니다! 이것은 정확히 내가 성취하려고 시도한 것입니다. –