ASCII chart rendering for terminal-based visualization.
Provides LTTB (Largest Triangle Three Buckets) downsampling and ASCII line/scatter plot rendering for use in :print and :pprint viewers.
Main entry points:
lttb-downsample - reduce points while preserving visual shaperender-chart - render points as ASCII chart, returns vector of stringsASCII chart rendering for terminal-based visualization. Provides LTTB (Largest Triangle Three Buckets) downsampling and ASCII line/scatter plot rendering for use in :print and :pprint viewers. Main entry points: - `lttb-downsample` - reduce points while preserving visual shape - `render-chart` - render points as ASCII chart, returns vector of strings
(lttb-downsample points target-count)Downsample points using Largest Triangle Three Buckets algorithm.
LTTB preserves the visual shape of the data by selecting points that form the largest triangles, keeping visually significant features.
Parameters: points - sequence of [x y] coordinate pairs (must be sorted by x) target-count - desired number of output points
Returns: Vector of [x y] pairs with at most target-count points. If points count <= target-count, returns points unchanged.
Algorithm:
Downsample points using Largest Triangle Three Buckets algorithm.
LTTB preserves the visual shape of the data by selecting points that
form the largest triangles, keeping visually significant features.
Parameters:
points - sequence of [x y] coordinate pairs (must be sorted by x)
target-count - desired number of output points
Returns:
Vector of [x y] pairs with at most target-count points.
If points count <= target-count, returns points unchanged.
Algorithm:
1. Always keep first and last points
2. Divide middle points into (target-count - 2) buckets
3. For each bucket, select point forming largest triangle with
previous selected point and average of next bucket(render-chart points
{:keys [width height x-label y-label dimension point-char
line-char title]
:or {width 80 height 20 point-char \* line-char \.}})Render points as an ASCII chart.
Parameters: points - sequence of [x y] coordinate pairs opts - options map: :width - total chart width in characters (default 80) :height - total chart height in lines (default 20) :x-label - x-axis label (optional) :y-label - y-axis label (optional) :dimension - :time or :memory for SI unit formatting (optional) :point-char - character for points (default *) :line-char - character for lines, nil to disable (default .) :title - chart title (optional)
Returns: Vector of strings, one per line, representing the chart. Empty vector if points is empty or has fewer than 1 point.
Render points as an ASCII chart.
Parameters:
points - sequence of [x y] coordinate pairs
opts - options map:
:width - total chart width in characters (default 80)
:height - total chart height in lines (default 20)
:x-label - x-axis label (optional)
:y-label - y-axis label (optional)
:dimension - :time or :memory for SI unit formatting (optional)
:point-char - character for points (default \*)
:line-char - character for lines, nil to disable (default \.)
:title - chart title (optional)
Returns:
Vector of strings, one per line, representing the chart.
Empty vector if points is empty or has fewer than 1 point.(render-chart-simple points)(render-chart-simple points width)Simplified chart rendering for quick visualizations.
Takes just points and optional width, using sensible defaults. Returns vector of strings.
Simplified chart rendering for quick visualizations. Takes just points and optional width, using sensible defaults. Returns vector of strings.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |