Skip to content

feat: add terminal chart visualization for financial data#132

Open
liuxiaopai-ai wants to merge 1 commit intovirattt:mainfrom
liuxiaopai-ai:feat/terminal-charts
Open

feat: add terminal chart visualization for financial data#132
liuxiaopai-ai wants to merge 1 commit intovirattt:mainfrom
liuxiaopai-ai:feat/terminal-charts

Conversation

@liuxiaopai-ai
Copy link

Closes #63

Adds automatic Unicode chart rendering for financial data in agent responses. Charts are appended below existing tables — the original table output is preserved.

What it does

When the agent returns a markdown table with numeric data, the formatter now detects chart opportunities and appends a visual:

Bar chart — for comparison data (e.g. company revenue side-by-side):

  📊 Revenue
  
  Apple             ██████████████████████████████████████  $394.3B
  Google            ████████████████████████████████        $307.4B
  Microsoft         ████████████████████████████            $245.1B

Sparkline — for time-series trends (e.g. quarterly earnings):

  📈 Revenue (2020–2024)
  ▁▂▅▇█  $274.5B → $394.3B (+43.6%)

How it works

  • detectChartOpportunity() analyzes parsed table columns — if it finds a label/date column paired with a numeric column, it suggests a chart type
  • Date-like labels (years, quarters, YYYY-MM) → sparkline; otherwise → bar chart
  • Integrated into the existing formatResponse() pipeline, runs before table boxing
  • Uses theme colors (colors.primary) and respects dimensions.boxWidth

Changes

File What
src/utils/charts.ts Chart engine — bar chart, sparkline, detection, number formatting
src/utils/charts.test.ts 32 tests covering all chart functions and edge cases
src/utils/markdown-table.ts 2-line integration into formatResponse()

Tests

32 new tests, all passing. Full suite (41 tests) green. bun run typecheck clean.

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.

Feature Request: Optional Visual/Chart Output for Dexter

1 participant