BarChart
A horizontal bar chart renderer.
Usage
BarChart()Parameters
title: str = "Chart"-
Chart title displayed above the bars.
width: int = 40-
Maximum bar width in characters.
Attributes
title-
Chart title.
width-
Bar width cap.
data: dict[str, float]-
Mapping of labels to values.
Methods
| Name | Description |
|---|---|
| add() | Add a data point to the chart. |
| render() | Render the chart as a text string. |
add()
Add a data point to the chart.
Usage
add(label, value)Parameters
label: str-
Bar label.
value: float-
Numeric value.
render()
Render the chart as a text string.
Usage
render()Returns
str-
Multi-line string with the rendered bar chart.