Commit 92650f1
authored
Optionally include bar chart renderings for
Related #336.
This PR adds a `--chart` (`-c`) flag to the `klog report` command, which
includes bar chart diagrams in the output like so:
```
$ klog report --chart worktimes.klg
Total
2025 Jan Tue 14. 6h ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Thu 16. 7h30m ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Fri 17. 6h45m ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Sat 18. 8h ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Mon 20. 3h20m ▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Wed 22. 7h45m ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
Sat 25. 7h15m ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇
========
46h35m
```
The default resolution of the bars depends on the aggregation mode.
(Remember: aggregation defaults to daily, unless specified via
`--aggregate`/`-a`). The default resolution aims to make for a good
balance between granularity and row width for typical usage scenarios
(e.g., tracking work times). The resolution can be overridden with the
`--chart-res` flag; it needs to be a positive integer, denoting the
number of minutes per rendered block.
One implementation note for reference: I originally tried to use
Unicode’s [“eighths” type block
characters](https://www.compart.com/en/unicode/block/U+2580) to make the
bars more precise. This didn’t work out so well, however, because on
some systems, the full block and the “eighths” blocks render at a
slightly different height, which looks weird.klog report
1 parent dcf38a4 commit 92650f1
3 files changed
+305
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
54 | | - | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| 69 | + | |
62 | 70 | | |
63 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
64 | 75 | | |
65 | | - | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
| |||
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
| |||
99 | 113 | | |
100 | 114 | | |
101 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
102 | 119 | | |
103 | 120 | | |
104 | 121 | | |
105 | 122 | | |
106 | 123 | | |
107 | 124 | | |
108 | 125 | | |
109 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
110 | 129 | | |
111 | 130 | | |
| 131 | + | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
116 | 136 | | |
117 | 137 | | |
118 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
119 | 142 | | |
120 | 143 | | |
121 | 144 | | |
122 | 145 | | |
123 | 146 | | |
124 | 147 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
131 | 170 | | |
132 | | - | |
133 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
134 | 183 | | |
135 | 184 | | |
136 | 185 | | |
| |||
169 | 218 | | |
170 | 219 | | |
171 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
0 commit comments