Matrix_chartsSourceTerminal charts rendered to a Grid.t.
Matrix_charts renders line, scatter, bar, heatmap, candlestick, and other chart types into a terminal grid. Charts are immutable specifications built from composable Mark.t values, then compiled into a Layout.t for drawing and interaction.
The typical workflow is:
t by layering marks (lines, bars, scatter, etc.).View.t (zoom and pan belong in your model, not the chart).draw which compiles a Layout.t and renders to a Grid.t.Layout + Hit + Overlay for hover tooltips, crosshairs, snapping, and zoom-to-cursor.Cell coordinates (px, py) are integer terminal-cell positions. (0, 0) is the top-left corner of the grid.
Data coordinates (x, y) are floating-point values in the data domain. Convert between systems with Layout.data_of_px and Layout.px_of_data.
Some marks support sub-cell resolution (e.g. `Braille2x4 renders 2×4 dots per cell). Sub-cell rendering is purely visual; all coordinates in the API remain in cell units.
Axis label formatters.
Compiled chart layout for coordinate mapping, hit-testing, and interaction.
The type for manual frame configurations. margins is (top, right, bottom, left) in cells.
type frame = | AutoCompute margins from axis/label sizes.
*)| Manual of frame_configExplicit margins and padding.
*)The type for frame modes.
The type for chart titles.
manual_frame () is a Manual frame. margins defaults to (0, 0, 0, 0). inner_padding defaults to 0, clamped to >= 0.
empty () is an empty chart with no marks. Gridlines are hidden by default; use with_grid to enable them. theme defaults to Theme.default.
make marks is a chart from marks. Marks render in list order (first mark is drawn first, last is on top). theme defaults to Theme.default.
with_theme theme t is t with the given theme. Axis and gridline styles are updated to inherit from the new theme.
with_title text t is t with chart title text.
with_y_scale scale t is t with primary y-axis scale scale.
with_y2_scale scale t enables and sets the secondary y-axis scale.
with_axes t configures the primary axes. Only provided axes are replaced; omitted axes keep their current configuration.
with_y2_axis axis t enables and configures the secondary y-axis.
with_grid g t is t with background gridlines g.
add mark t appends mark to the chart. Marks render in add order (later marks draw on top).
Shorthand for add (Mark.xxx ...) t, enabling pipeline-style chart construction.
val line :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?resolution:Raster.resolution ->
?pattern:Charset.line_pattern ->
?glyph:string ->
?y_axis:Mark.y_axis_selector ->
x:('a -> float) ->
y:('a -> float) ->
'a array ->
t ->
tline ~x ~y data t is add (Mark.line ~x ~y data) t. See Mark.line.
val line_gaps :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?resolution:Raster.resolution ->
?pattern:Charset.line_pattern ->
?glyph:string ->
?y_axis:Mark.y_axis_selector ->
x:('a -> float) ->
y:('a -> float option) ->
'a array ->
t ->
tline_gaps ~x ~y data t is add (Mark.line_gaps ~x ~y data) t. See Mark.line_gaps.
val scatter :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?glyph:string ->
?mode:Mark.scatter_mode ->
?y_axis:Mark.y_axis_selector ->
x:('a -> float) ->
y:('a -> float) ->
'a array ->
t ->
tscatter ~x ~y data t is add (Mark.scatter ~x ~y data) t. See Mark.scatter.
val bar :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?direction:Mark.direction ->
?mode:Mark.bar_mode ->
category:('a -> string) ->
value:('a -> float) ->
'a array ->
t ->
tbar ~category ~value data t is add (Mark.bar ~category ~value data) t. See Mark.bar.
val stacked_bar :
?id:Mark.id ->
?direction:Mark.direction ->
?gap:int ->
?size:int ->
?mode:Mark.bar_mode ->
Mark.stacked_bar array ->
t ->
tstacked_bar data t is add (Mark.stacked_bar data) t. See Mark.stacked_bar.
val rule :
?id:Mark.id ->
?style:Ansi.Style.t ->
?direction:Mark.direction ->
?pattern:Charset.line_pattern ->
?y_axis:Mark.y_axis_selector ->
float ->
t ->
trule value t is add (Mark.rule value) t. See Mark.rule.
val heatmap :
?id:Mark.id ->
?color_scale:Ansi.Color.t array ->
?value_range:(float * float) ->
?auto_value_range:bool ->
?agg:Mark.heatmap_agg ->
?mode:Mark.heatmap_mode ->
x:('a -> float) ->
y:('a -> float) ->
value:('a -> float) ->
'a array ->
t ->
theatmap ~x ~y ~value data t is add (Mark.heatmap ~x ~y ~value data) t. See Mark.heatmap.
val candles :
?id:Mark.id ->
?bullish:Ansi.Style.t ->
?bearish:Ansi.Style.t ->
?width:Mark.candle_width ->
?body:Mark.candle_body ->
?y_axis:Mark.y_axis_selector ->
Mark.ohlc array ->
t ->
tcandles data t is add (Mark.candles data) t. See Mark.candles.
val circle :
?id:Mark.id ->
?style:Ansi.Style.t ->
?resolution:Raster.resolution ->
?y_axis:Mark.y_axis_selector ->
cx:('a -> float) ->
cy:('a -> float) ->
r:('a -> float) ->
'a array ->
t ->
tcircle ~cx ~cy ~r data t is add (Mark.circle ~cx ~cy ~r data) t. See Mark.circle.
shade ~min ~max t is add (Mark.shade ~min ~max ()) t. See Mark.shade.
column_bg x t is add (Mark.column_bg x) t. See Mark.column_bg.
val area :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?baseline:Mark.area_baseline ->
?resolution:Raster.resolution ->
?y_axis:Mark.y_axis_selector ->
x:('a -> float) ->
y:('a -> float) ->
'a array ->
t ->
tarea ~x ~y data t is add (Mark.area ~x ~y data) t. See Mark.area.
val fill_between :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?resolution:Raster.resolution ->
?y_axis:Mark.y_axis_selector ->
x:('a -> float) ->
y_low:('a -> float) ->
y_high:('a -> float) ->
'a array ->
t ->
tfill_between ~x ~y_low ~y_high data t is add (Mark.fill_between ~x ~y_low ~y_high data) t. See Mark.fill_between.
val histogram :
?id:Mark.id ->
?label:string ->
?style:Ansi.Style.t ->
?bins:Mark.bin_method ->
?normalize:Mark.histogram_normalize ->
x:('a -> float) ->
'a array ->
t ->
thistogram ~x data t is add (Mark.histogram ~x data) t. See Mark.histogram.
layout t ~width ~height compiles t into a Layout.t without rendering. Use this when you need layout information (coordinate mapping, hit-testing) without drawing.
view defaults to View.empty.x and y are horizontal and vertical offsets. Default 0.width and height are clamped to >= 1.val draw :
?view:View.t ->
?x:int ->
?y:int ->
t ->
Grid.t ->
width:int ->
height:int ->
Layout.tdraw t grid ~width ~height renders t to grid and returns the compiled layout.
Fills the chart region with the theme background, then draws gridlines, marks (in add order), axes, and title. The returned Layout.t can be used for hit-testing and overlay drawing.
view defaults to View.empty.x and y are horizontal and vertical offsets. Default 0.width and height are clamped to >= 1.