Skip to content

Sparkline

Added in version 0.27.0

A widget that is used to visually represent numerical data.

  • Focusable
  • Container

Examples

Basic example

The example below illustrates the relationship between the data, its length, the width of the sparkline, and the number of bars displayed.

Tip

The sparkline data is split into equally-sized chunks. Each chunk is represented by a bar and the width of the sparkline dictates how many bars there are.

SparklineBasicApp

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

data = [1, 2, 2, 1, 1, 4, 3, 1, 1, 8, 8, 2]  # (1)!


class SparklineBasicApp(App[None]):
    CSS_PATH = "sparkline_basic.tcss"

    def compose(self) -> ComposeResult: