Open mbforbes opened 3 years ago
Correct it's the normalization, the width is the overall width and not necessarily what it will draw, just what it tries to fit the data in to.
I think to get consistent widths from call to call it will need a normalization factor passed in, so it treats data the same across calls.
I'm also experiencing this on the CLI. EG:
$ termgraph --version
termgraph v0.5.3
$ cat data.txt
2024-07-23T12:48:01-04:00 2.27 97.73
2024-07-23T14:48:01-04:00 9.3 90.7
2024-07-23T16:48:01-04:00 12.93 87.07
2024-07-23T18:48:01-04:00 19.72 80.28
2024-07-23T20:48:01-04:00 23.6 76.4
2024-07-23T22:48:01-04:00 29.82 70.18
2024-07-24T00:48:01-04:00 31.33 68.67
$ cat data.txt | termgraph --stacked
2024-07-23T12:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-23T14:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-23T16:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-23T18:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-23T20:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-23T22:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
2024-07-24T00:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100.00
If I truncate the decimals, essentially turning the floats into integers, the problem goes away:
$ cat data2.txt
2024-07-23T12:48:01-04:00 2 97
2024-07-23T14:48:01-04:00 9 90
2024-07-23T16:48:01-04:00 12 87
2024-07-23T18:48:01-04:00 19 80
2024-07-23T20:48:01-04:00 23 76
2024-07-23T22:48:01-04:00 29 70
2024-07-24T00:48:01-04:00 31 68
$ cat data2.txt | termgraph --stacked
2024-07-23T12:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-23T14:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-23T16:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-23T18:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-23T20:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-23T22:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
2024-07-24T00:48:01-04:00: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99.00
Hi there,
Thank you very much for providing this library!
I'm attempting to use it to print a live indicator as a debugging aid. (I'm charting how much GPU memory is used vs free). I'm setting width=60 on every call. However, the total bar width changes when the data changes!
I'm wondering if the issue is with normalization not accounting for stacked charts?
In case it helps, here's how I'm calling it:
Many thanks for any tips, and apologies if I'm confused here!