Skip to content

bug(render): chart_sparkline + git_commits_activity produces sparse/uninformative output #83

Closed

Description

@unhappychoice

Observed

On the dogfood .splashboard/config.toml:

[[widget]]
id = "commits"
fetcher = "git_commits_activity"
render = "chart_sparkline"

renders nothing (blank). The ci_history sparkline rendered fine.

Root cause

ratatui::widgets::Sparkline::render_sparkline (0.29.0, sparkline.rs:350) takes the first min(area.width, data.len()) points from the head:

let max_index = min(spark_area.width as usize, self.data.len());
for (i, item) in self.data.iter().take(max_index).enumerate() {

Meanwhile git_commits_activity returns a NumberSeries of 364 points (52 weeks × 7 days) ordered oldest → newest.

→ In a 58-col widget, "the oldest 58 days from the head" get drawn. In this repo, commits are clustered in the last 3 days, leaving the other 361 at zero, so the first 58 days are all zero → blank.

Confirmed via isolation tests (debug_boundary / debug_dogfood_sparse; results shown are pre-fix):

len=31 width=30  → tail spike visible
len=33 width=30  → blank
len=40 width=30  → blank

The moment len > width, the tail data is dropped.

Fix

Tail-slice in src/render/chart_sparkline.rs::render_sparkline before handing data to ratatui:

let start = data.values.len().saturating_sub(area.width as usize);
let visible = &data.values[start..];
frame.render_widget(Sparkline::default().data(visible), area);

The sparkline's semantics are "trend of the most recent N points", so tail-priority is the right answer. When data.len() <= area.width, behavior is unchanged (all data drawn).

Added the regression test tail_window_is_rendered_when_data_exceeds_width.

Out of scope (separate issues)

Activity

  1. added
    bug
    render
    on Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrender

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions