First chart¶
This tutorial walks through the fastest path from install to useful output.
Install¶
pip install textcharts
Render a basic bar chart¶
from textcharts import BarChart, BarData
data = [
BarData(label="Fiction", value=18.4, is_best=True),
BarData(label="Children", value=14.2),
BarData(label="Comics", value=9.8, is_worst=True),
]
chart = BarChart(
data=data,
title="April Bookstore Revenue",
metric_label="k USD",
)
print(chart.render())
What to expect¶
Labels are aligned and sorted for readability.
Best and worst values can be highlighted through the data model.
Unicode and color are enabled by default when the terminal supports them.
Build a chart from structured data¶
Most charts have a dedicated data model:
textcharts.BarDatatextcharts.LinePointtextcharts.ScatterPointtextcharts.SpeedupDatatextcharts.SummaryStats
Use those models directly. Convenience factory helpers are also available for one-shot chart creation — see Factory helpers.
Next steps¶
Read Choosing a chart to choose the right visualization.
Read Configuration guide to control width, color, and Unicode.
Use Chart classes and data models for chart-specific constructors and data models.