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

BrailleCanvas
A 2x4 sub-cell braille canvas for plotting terminal-native 2D graphics.
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..1 values to colors.

Functions

clamp01(double value) double
Clamps value to 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) within area.
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.
drawGroupedHistogram(Screen screen, Rectangle area, List<List<double>> seriesList, {List<UvStyle> styles = 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, int groupGap = 1, int? barWidth, bool drawAxisLine = true}) → void
Draws a grouped (side-by-side) multi-series vertical bar chart.
drawHeatmap(Screen screen, Rectangle area, List<List<double>> grid, {ChartRamp? ramp, bool useBackground = true, String glyph = ' ', bool showGrid = false, int gridRows = 3, int gridCols = 3, UvStyle gridStyle = const UvStyle(), List<String>? xLabels, List<String>? yLabels, UvStyle labelStyle = const UvStyle()}) → void
Draws a heatmap of the 2-D grid values into area on screen.
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, int? barWidth, bool drawAxisLine = true}) → void
Draws a vertical bar histogram of values into area on screen.
drawHorizontalGroupedHistogram(Screen screen, Rectangle area, List<List<double>> seriesList, {List<UvStyle> styles = const [UvStyle()], UvStyle axisStyle = const UvStyle(), UvStyle gridStyle = const UvStyle(), UvStyle labelStyle = const UvStyle(), bool showAxis = true, bool showGrid = false, int gridRows = 0, int gridCols = 3, List<String>? yLabels, String barChar = '█', int barGap = 1, int groupGap = 1, int? barWidth, bool drawAxisLine = true}) → void
Draws a grouped multi-series horizontal bar chart.
drawHorizontalStackedHistogram(Screen screen, Rectangle area, List<List<double>> seriesList, {List<UvStyle> styles = const [UvStyle()], UvStyle axisStyle = const UvStyle(), UvStyle gridStyle = const UvStyle(), UvStyle labelStyle = const UvStyle(), bool showAxis = true, bool showGrid = false, int gridRows = 0, int gridCols = 3, List<String>? yLabels, String barChar = '█', int barGap = 1, int groupGap = 1, int? barWidth, bool drawAxisLine = true}) → void
Draws a stacked multi-series horizontal bar chart.
drawLegend(Screen screen, Rectangle area, List<ChartLegendEntry> entries, {int columns = 1, int rowGap = 0}) → void
Draws a legend for the given entries within area.
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, double? minValue, double? maxValue}) → void
Draws a line chart of values into area on screen.
drawMultiSeriesLineChart(Screen screen, Rectangle area, List<List<double>> seriesList, {List<UvStyle> styles = const [UvStyle()], UvStyle gridStyle = const UvStyle(), UvStyle labelStyle = const UvStyle(), bool showGrid = false, int gridRows = 3, int gridCols = 3, bool showMarkers = true, String markerChar = '●', List<String>? xLabels, List<String>? yLabels, double? minValue, double? maxValue}) → void
Draws a multi-series line chart into area on screen.
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 values into area on screen.
drawRibbonChart(Screen screen, Rectangle area, List<List<double>> series, {List<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 series into area on screen.
drawSparkline(Screen screen, Rectangle area, List<double> values, {UvStyle style = const UvStyle(), bool showGrid = false, UvStyle gridStyle = const UvStyle(), double baseline = 0.0, double? minValue, double? maxValue, UvStyle? gradientLow, UvStyle? gradientHigh}) → void
Draws a compact sparkline of values into area on screen.
drawStackedHistogram(Screen screen, Rectangle area, List<List<double>> seriesList, {List<UvStyle> styles = 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, int groupGap = 1, int? barWidth, bool drawAxisLine = true}) → void
Draws a stacked multi-series vertical bar chart.
normalize(double value, double min, double max) double
Normalizes value into the 0..1 range between min and max.
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 values to fit the given width.
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.