X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftally%2Ftally.c;h=b89b0600ac301d0f5d088cb5a31176c841e1c8c3;hp=b3ac863ba68119aedc59973b72c1d3716bb35867;hb=18636637ee013ef828cb04b2b7bb4a4922324475;hpb=097857e6c09bf9696797fe08cd4241b8315f9c9a diff --git a/ccan/tally/tally.c b/ccan/tally/tally.c index b3ac863b..b89b0600 100644 --- a/ccan/tally/tally.c +++ b/ccan/tally/tally.c @@ -455,14 +455,17 @@ char *tally_histogram(const struct tally *tally, } for (i = 0; i < height; i++) { - unsigned covered = 1; - count = (double)tally->counts[i] / largest_bucket * (width-1)+1; + unsigned covered = 1, row; - if (i == 0) + /* People expect minimum at the bottom. */ + row = height - i - 1; + count = (double)tally->counts[row] / largest_bucket * (width-1)+1; + + if (row == 0) covered = snprintf(p, width, "%zi", tally->min); - else if (i == height - 1) + else if (row == height - 1) covered = snprintf(p, width, "%zi", tally->max); - else if (i == bucket_of(tally->min, tally->step_bits, 0)) + else if (row == bucket_of(tally->min, tally->step_bits, 0)) *p = '+'; else *p = '|';