Show session lengths in ten categories
The Focus view grouped sessions into six buckets, too coarse to see a rhythm. There are now ten: under 5m, 5-15m, 15-25m, 25-45m, 45m-1h, 1h-1h30m, 1h30m-2h, 2-3h, 3-4h and 4h or more. 25 minutes is a classic pomodoro, and the long end separates 3-4h stretches from 4h+ hyperfocus. Ten labelled columns don't fit side by side, so the chart is now drawn with horizontal bars: every label stays readable at any width. The buckets are one constant (analysis::focus::SESSION_BUCKETS); a new test pins down where sessions land, including an exact boundary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
49e14b820a
commit
ae9e1b1f08
2 files changed
+52
-9
No files matched your search
@@ -12,7 +12,7 @@ use jiff::civil::{Date, Weekday};
|
||||
use jiff::{SignedDuration, ToSpan};
|
||||
use ratatui::Frame;
|
||||
use ratatui::crossterm::event::{MouseButton, MouseEvent, MouseEventKind};
|
||||
use ratatui::layout::{Constraint, Layout, Position, Rect};
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Position, Rect};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::symbols::Marker;
|
||||
use ratatui::text::{Line, Span};
|
||||
@@ -375,14 +375,16 @@ impl Insights {
|
||||
.style(Style::new().fg(ctx.theme.working))
|
||||
})
|
||||
.collect();
|
||||
let bar_width = (chart_area.width.saturating_sub(2) / SESSION_BUCKETS.len() as u16)
|
||||
.saturating_sub(2)
|
||||
.clamp(3, 12);
|
||||
// Horizontal bars, one row each, so every label fits; a blank row
|
||||
// between bars when there's room.
|
||||
let rows = chart_area.height.saturating_sub(2);
|
||||
let gap = u16::from(rows >= 2 * SESSION_BUCKETS.len() as u16 - 1);
|
||||
frame.render_widget(
|
||||
BarChart::new(bars)
|
||||
.direction(Direction::Horizontal)
|
||||
.block(section(" How long your sessions last ", ctx))
|
||||
.bar_width(bar_width)
|
||||
.bar_gap(2)
|
||||
.bar_width(1)
|
||||
.bar_gap(gap)
|
||||
.value_style(Style::new().fg(ratatui::style::Color::Black).bg(ctx.theme.working)),
|
||||
chart_area,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user