mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
* Sparkline widget proof of concept. * Address review comment. Related comments: https://github.com/Textualize/textual/pull/2631\#discussion_r1202894414 * Blend background colours. * Add widget sparkline. * Add snapshot tests. * Add documentation. * Update roadmap. * Address review feedback. Relevant comments: https://github.com/Textualize/textual/pull/2631\#discussion_r1210394532, https://github.com/Textualize/textual/pull/2631\#discussion_r1210442013 * Improve docs. Relevant comments: https://github.com/Textualize/textual/pull/2631\#issuecomment-1568529074 * Update snapshot app titles. * Don't init summary function with None Related comments: https://github.com/Textualize/textual/pull/2631\#discussion_r1211666076 * Apply suggestions from code review Co-authored-by: Dave Pearson <davep@davep.org> * Improve wording. * Improve wording. * Simplify example. --------- Co-authored-by: Dave Pearson <davep@davep.org>
23 lines
588 B
Python
23 lines
588 B
Python
import random
|
|
from statistics import mean
|
|
|
|
from textual.app import App, ComposeResult
|
|
from textual.widgets._sparkline import Sparkline
|
|
|
|
random.seed(73)
|
|
data = [random.expovariate(1 / 3) for _ in range(1000)]
|
|
|
|
|
|
class SparklineSummaryFunctionApp(App[None]):
|
|
CSS_PATH = "sparkline.css"
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Sparkline(data, summary_function=max) # (1)!
|
|
yield Sparkline(data, summary_function=mean) # (2)!
|
|
yield Sparkline(data, summary_function=min) # (3)!
|
|
|
|
|
|
app = SparklineSummaryFunctionApp()
|
|
if __name__ == "__main__":
|
|
app.run()
|