package matrix

  1. Overview
  2. Docs
Fast, modern terminal toolkit for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/matrix.charts/Matrix_charts/View/index.html

Module Matrix_charts.ViewSource

Viewport windowing for zoom and pan.

A view constrains which portion of the data domain is visible. Store a t in your application model and pass it to Matrix_charts.draw. Use empty to show the full data extent.

All window operations produce valid windows: min is always < max, with a minimum span enforced to prevent degenerate ranges.

Sourcetype window = {
  1. min : float;
  2. max : float;
}

The type for 1D ranges. Invariant: min < max.

Sourcetype t = {
  1. x : window option;
  2. y : window option;
  3. y2 : window option;
}

The type for viewport state. None on any axis means "show full domain".

Sourceval empty : t

No constraints on any axis.

Sourceval set_x : window option -> t -> t

set_x w v is v with x-axis window w.

Sourceval set_y : window option -> t -> t

set_y w v is v with y-axis window w.

Sourceval set_y2 : window option -> t -> t

set_y2 w v is v with secondary y-axis window w.

Sourceval window : min:float -> max:float -> window

window ~min ~max is a window over [min, max]. If min > max the values are swapped. A minimum span is enforced.

Sourceval zoom : window -> factor:float -> window

zoom w ~factor zooms around the centre of w. factor > 1 zooms in (smaller range), factor < 1 zooms out. Non-positive factors are treated as 1.0.

Sourceval zoom_around : window -> center:float -> factor:float -> window

zoom_around w ~center ~factor zooms around center, preserving its relative position within the window.

Sourceval pan : window -> delta:float -> window

pan w ~delta shifts w by delta data units.

Sourceval clamp : domain:window -> window -> window

clamp ~domain w restricts w to fit within domain. If w is wider than domain, returns domain. Otherwise slides w to the nearest position that fits.