API reference¶
Package overview¶
The top-level package re-exports the preferred public API:
Category |
Symbols |
|---|---|
Chart classes |
|
Shared configuration |
|
Data models |
|
Factory helpers |
|
Use Chart classes and data models and Factory helpers for the canonical symbol-level documentation.
Shared configuration and utilities¶
Base classes and utilities for ASCII chart rendering.
- textcharts.base.outlier_severity_markers(value, scale_max)[source]¶
Return 1-4
▸characters indicating how far value exceeds scale_max.- Thresholds are logarithmic:
≤ 2× → ▸ ≤ 5× → ▸▸ ≤ 10× → ▸▸▸ > 10× → ▸▸▸▸
- Parameters:
value (float)
scale_max (float)
- Return type:
str
- textcharts.base.compute_percentile_linear(values, percentile, *, presorted=False)[source]¶
Compute percentile using linear interpolation between adjacent ranks.
- Parameters:
values (Sequence[float])
percentile (float)
presorted (bool)
- Return type:
float
- textcharts.base.robust_p95(values)[source]¶
Return nearest-rank P95 with positive-tail fallback for zero-heavy data.
- Parameters:
values (Sequence[float])
- Return type:
float
- class textcharts.base.ColorMode(*values)[source]¶
Bases:
EnumTerminal color capability levels.
- NONE = 'none'¶
- BASIC = 'basic'¶
- EXTENDED = 'extended'¶
- TRUECOLOR = 'truecolor'¶
- class textcharts.base.TerminalCapabilities(width=80, height=24, color_mode=ColorMode.NONE, unicode_support=True, interactive=False)[source]¶
Bases:
objectDetected terminal capabilities.
- Parameters:
width (int)
height (int)
color_mode (ColorMode)
unicode_support (bool)
interactive (bool)
- width: int = 80¶
- height: int = 24¶
- unicode_support: bool = True¶
- interactive: bool = False¶
- textcharts.base.detect_terminal_capabilities()[source]¶
Detect terminal capabilities for rendering decisions.
- Return type:
- class textcharts.base.TerminalColors(color_mode=ColorMode.EXTENDED, RESET='\x1b[0m', BOLD='\x1b[1m', DIM='\x1b[2m', UNDERLINE='\x1b[4m')[source]¶
Bases:
objectTerminal color utilities using ANSI escape codes.
- Parameters:
color_mode (ColorMode)
RESET (str)
BOLD (str)
DIM (str)
UNDERLINE (str)
- RESET: str = '\x1b[0m'¶
- BOLD: str = '\x1b[1m'¶
- DIM: str = '\x1b[2m'¶
- UNDERLINE: str = '\x1b[4m'¶
- fg(color)[source]¶
Generate foreground color escape code.
- Parameters:
color (str | int)
- Return type:
str
- class textcharts.base.ChartOptions(width=None, height=None, use_color=True, use_unicode=True, title=None, show_legend=True, show_values=True, theme='light', outlier_cap=None, _capabilities=None)[source]¶
Bases:
objectConfiguration options for ASCII chart rendering.
- Parameters:
width (int | None)
height (int | None)
use_color (bool)
use_unicode (bool)
title (str | None)
show_legend (bool)
show_values (bool)
theme (str)
outlier_cap (float | None)
_capabilities (TerminalCapabilities | None)
- width: int | None = None¶
- height: int | None = None¶
- use_color: bool = True¶
- use_unicode: bool = True¶
- title: str | None = None¶
- show_legend: bool = True¶
- show_values: bool = True¶
- theme: str = 'light'¶
- outlier_cap: float | None = None¶
- get_effective_width()[source]¶
Get effective chart width, constrained to reasonable bounds.
- Return type:
int
- get_palette()[source]¶
Get the categorical palette for the configured theme.
- Return type:
tuple[str, …]
- class textcharts.base.ChartBase(options=None, subtitle=None, title=None, subject=None)[source]¶
Bases:
ABCAbstract base class for ASCII chart renderers.
- Parameters:
options (ChartOptions | None)
subtitle (str | None)
title (str | None)
subject (str | None)
- subtitle: str | None¶