Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally include bar chart renderings for klog report #338

Merged
merged 5 commits into from
Feb 8, 2025
Merged

Conversation

jotaen
Copy link
Owner

@jotaen jotaen commented Feb 8, 2025

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 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.

@jotaen jotaen merged commit 92650f1 into main Feb 8, 2025
8 checks passed
@jotaen jotaen deleted the report-chart branch February 8, 2025 11:56
@jotaen jotaen changed the title Provide --chart flag on klog report command Optionally include bar chart renderings for klog report Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant