charting library
Charting primitives for terminal-native visualizations.
Provides reusable renderers for sparklines, histograms, heatmaps, and ribbon/area charts that draw into UV buffers.
Classes
- ChartCanvas
- A convenience canvas for rendering charts into UV buffers.
- ChartLegendEntry
- A single entry in a chart legend.
- ChartRamp
-
Discrete color ramp for mapping normalized
0..1values to colors.
Functions
-
clamp01(
double value) → double -
Clamps
valueto the range 0..1, treating NaN as 0. -
drawAxisLabels(
Screen screen, Rectangle area, {List< String> ? xLabels, List<String> ? yLabels, UvStyle style = const UvStyle()}) → void -
Draws axis labels along the X and/or Y edges of
area. -
drawCrosshair(
Screen screen, Rectangle area, int x, int y, {UvStyle style = const UvStyle(), String hChar = '─', String vChar = '│', String intersectionChar = '┼', bool drawOnEmpty = true}) → void -
Draws a crosshair overlay at (
x,y) withinarea. -
drawGrid(
Screen screen, Rectangle area, {int rows = 3, int cols = 3, UvStyle style = const UvStyle(), String hChar = '┄', String vChar = '┆', String intersectionChar = '┼', bool preserveBackground = false}) → void -
Draws a grid of horizontal and vertical guide lines within
area. -
drawHeatmap(
Screen screen, Rectangle area, List< List< grid, {ChartRamp? ramp, bool useBackground = true, String glyph = ' ', bool showGrid = false, int gridRows = 3, int gridCols = 3, UvStyle gridStyle = const UvStyle(), List<double> >String> ? xLabels, List<String> ? yLabels, UvStyle labelStyle = const UvStyle()}) → void -
Draws a heatmap of the 2-D
gridvalues intoareaonscreen. -
drawHistogram(
Screen screen, Rectangle area, List< double> values, {UvStyle barStyle = const UvStyle(), UvStyle axisStyle = const UvStyle(), UvStyle gridStyle = const UvStyle(), UvStyle labelStyle = const UvStyle(), bool showAxis = true, bool showGrid = false, int gridRows = 3, int gridCols = 0, List<String> ? xLabels, List<String> ? yLabels, String barChar = '█', int barGap = 1}) → void -
Draws a vertical bar histogram of
valuesintoareaonscreen. -
drawLegend(
Screen screen, Rectangle area, List< ChartLegendEntry> entries, {int columns = 1, int rowGap = 0}) → void -
Draws a legend for the given
entrieswithinarea. -
drawLineChart(
Screen screen, Rectangle area, List< double> values, {UvStyle lineStyle = const UvStyle(), UvStyle gridStyle = const UvStyle(), UvStyle labelStyle = const UvStyle(), bool showGrid = false, int gridRows = 3, int gridCols = 3, bool showMarkers = true, String markerChar = '●', String lineChar = '•', List<String> ? xLabels, List<String> ? yLabels}) → void -
Draws a line chart of
valuesintoareaonscreen. -
drawPieChart(
Screen screen, Rectangle area, List< double> values, {List<UvStyle> ? styles, bool useBackground = true, bool donut = false, double innerRadiusRatio = 0.45, double cellAspect = 2.0, String glyph = ' '}) → void -
Draws a pie (or donut) chart of
valuesintoareaonscreen. -
drawRibbonChart(
Screen screen, Rectangle area, List< List< series, {List<double> >UvStyle> ? styles, bool normalizeTotals = true, String fillChar = '█', bool showGrid = false, int gridRows = 3, int gridCols = 0, UvStyle gridStyle = const UvStyle()}) → void -
Draws a stacked ribbon chart of multiple
seriesintoareaonscreen. -
drawSparkline(
Screen screen, Rectangle area, List< double> values, {UvStyle style = const UvStyle(), bool showGrid = false, UvStyle gridStyle = const UvStyle()}) → void -
Draws a compact sparkline of
valuesintoareaonscreen. -
normalize(
double value, double min, double max) → double -
Normalizes
valueinto the 0..1 range betweenminandmax. -
putText(
Screen screen, Rectangle area, int x, int y, String text, UvStyle style) → void -
renderChartLines(
int width, int height, ChartPainter painter) → List< String> - Renders a chart into a list of lines.
-
sampleSeries(
List< double> values, int width) → List<double> -
Down-samples or up-samples
valuesto fit the givenwidth. -
uvColorFromHex(
String hex, {UvColor fallback = const UvBasic16(7)}) → UvColor - Parses a hex color string (e.g. '#ff0000') into a UvColor.
-
uvStyleFromHex(
String hex, {String? backgroundHex, int attrs = 0}) → UvStyle - Creates a UvStyle from hex color strings for foreground and optional background.
Typedefs
- ChartPainter = void Function(Screen screen, Rectangle area)
- Signature for chart painters.