Skip to content

Refactor: Unified column layout engine #33

@gregeva

Description

@gregeva

Problem

ltl's bar graph column layout evolved from a simple 3-column system to a complex multi-column layout supporting up to 9 visible columns, vertical separators, compound columns (legend), and conditional visibility. The implementation grew incrementally, resulting in 5 overlapping data structures (%graph_width, @printed_column_widths, @printed_column_names, @printed_column_spacing, and two competing count variables) populated piecemeal across ~170 lines. Graph widths use hardcoded percentage tables (65/35, 62/21/17, etc.) that must be manually authored for each column count.

This causes bugs when adding columns (#27), blocks new column types (#26), and makes the rendering code fragile through cumulative $printed_chars tracking.

Solution

Replace the fragmented layout system with a unified column layout engine where each column is defined once with all its properties: name, sizing type, width, spacing, visibility, color, and rendering behavior.

Key Requirements

  • Column types: Fixed (timestamp, latency), content-driven (legend), proportional (all graph columns), separator (), and compound (legend as counts + spacing + rates sub-columns with spanning header)
  • Algorithmic width distribution: Replace hardcoded percentage tables with a focus/secondary algorithm that works for any column count
  • First-class visibility: Each column carries a visible flag; hiding triggers automatic redistribution
  • Fill-to-width rendering: Each column fills its allocated width independently, eliminating $printed_chars tracking
  • Color as column property: Color identity carried in column definition, not derived from position
  • Separators as layout elements: Modeled explicitly with adjacency visibility rules

Constraints

  • Output must be pixel-identical to current behavior for all option combinations
  • No Perl OO/classes — use idiomatic data structures
  • No new visual features — pure structural refactor

Detailed Requirements

See features/column-layout-refactor.md for the full requirements document covering all sections: column types, layout engine, headers, separators, colors, legend decomposition, rendering, testing strategy, and risks.

Approach

  1. Requirements document (this issue + feature file) ✅
  2. Prototype to validate design
  3. Iterate on prototype
  4. Phased implementation

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions