Skip to content

Conversation

uriyyo
Copy link
Contributor

@uriyyo uriyyo commented Oct 10, 2025

Make Sparkline be able to use not only 1 as a height value.

Demo app:

import random
from statistics import mean

from textual.containers import Grid

from textual.app import App, ComposeResult
from textual.widgets import Sparkline

random.seed(73)
data = [random.expovariate(1 / 3) for _ in range(1000)]


class SparklineAnyHeightApp(App[None]):
    DEFAULT_CSS = """
    SparklineAnyHeightApp {
        Sparkline {
            height: 1fr;
            border: round white;
        }
    }
    """

    def compose(self) -> ComposeResult:
        with Grid():
            yield Sparkline(data, summary_function=max)
            yield Sparkline(data, summary_function=mean)
            yield Sparkline(data, summary_function=min)
            yield Sparkline([*range(len(data))])
            yield Sparkline([1])
            yield Sparkline([])


if __name__ == "__main__":
    app = SparklineAnyHeightApp()
    app.run()

Result:
image

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@uriyyo uriyyo marked this pull request as ready for review October 10, 2025 12:44
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.

1 participant