-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow Sparkline to be of any height #6171
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
base: main
Are you sure you want to change the base?
Conversation
willmcgugan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Can I request a snapshot test?
See test_snapshots.py for examples. Can be very simple, just a single sparkline is all that is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Sparkline widget to support multi-line rendering at any height, not just a single line. The implementation adds a height parameter that controls how many terminal lines the sparkline uses, with taller sparklines providing more granular vertical resolution for data visualization.
Key Changes:
- Added
heightparameter toSparklinerenderable with appropriate default ofNone(defaulting to 1) - Updated rendering logic to distribute bar segments across multiple lines
- Modified edge case handling (empty data, single datapoint) to respect the height parameter
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/textual/renderables/sparkline.py | Core implementation: added height parameter, updated rendering algorithm to distribute bar segments across multiple lines, and fixed edge cases |
| src/textual/widgets/_sparkline.py | Widget integration: passes widget height to the sparkline renderable |
| tests/renderables/test_sparkline.py | Test coverage: added parametrized tests for heights 1, 2, and 3 |
| CHANGELOG.md | Documentation: added changelog entry for the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@willmcgugan Added snapshot test, hope I did it right 🙏 |
Make
Sparklinebe able to use not only 1 as a height value.Demo app:
Result:

Please review the following checklist.