TermUI.Widgets.LineChart (TermUI v0.2.0)

View Source

Line chart widget using Braille patterns for sub-character resolution.

Each Braille character cell is 2 dots wide and 4 dots tall, enabling smooth line rendering in text mode. Perfect for time series visualization.

Usage

LineChart.render(
  series: [
    %{data: [1, 3, 5, 2, 8], color: :blue},
    %{data: [2, 4, 3, 6, 4], color: :red}
  ],
  width: 40,
  height: 10
)

Braille Patterns

Braille patterns use Unicode range U+2800 to U+28FF. Each cell has 8 dots arranged as:

1 4
2 5
3 6
7 8

Summary

Functions

Converts coordinates to a single Braille character.

Returns an empty Braille character.

Returns a full Braille character (all dots).

Renders a line chart using Braille patterns.

Functions

dots_to_braille(dots)

@spec dots_to_braille([{0 | 1, 0..3}]) :: String.t()

Converts coordinates to a single Braille character.

Useful for drawing individual points.

empty_braille()

@spec empty_braille() :: String.t()

Returns an empty Braille character.

full_braille()

@spec full_braille() :: String.t()

Returns a full Braille character (all dots).

render(opts)

@spec render(keyword()) :: TermUI.Component.RenderNode.t()

Renders a line chart using Braille patterns.

Options

  • :series - List of series with data and optional color
  • :data - Single series data (alternative to :series)
  • :width - Chart width in characters (default: 40, max: 1000)
  • :height - Chart height in characters (default: 10, max: 500)
  • :min - Minimum Y value (default: auto)
  • :max - Maximum Y value (default: auto)
  • :show_axis - Show axis lines (default: false)
  • :style - Style for the chart