Module Matrix_charts.Layout Source Compiled chart layout for coordinate mapping, hit-testing, and interaction.
A layout is produced by Matrix_charts.draw or Layout and captures the computed coordinate mapping, plot region, and resolved scales. It bridges cell coordinates (from mouse/cursor input) and data coordinates (for tooltips, crosshairs, and snapping).
The type for compiled layouts.
Source type rect = { x : int; y : int; width : int; height : int; } The type for axis-aligned rectangles in cell coordinates.
Geometrysize l is (width, height) of the full chart area.
plot_rect l is the data plotting region, excluding axes, labels, and margins.
Source val is_inside_plot : t -> px :int -> py :int -> boolis_inside_plot l ~px ~py is true iff (px, py) falls within the plot region.
Domain and viewSource val y2_domain : t -> View.window optiony2_domain l is the secondary y-axis domain, or None if no secondary axis is configured.
x_view l is the currently visible x-axis range (may be a subset of the domain when zoomed).
y_view l is the currently visible y-axis range.
y2_view l is the currently visible secondary y-axis range.
Source val y_axis_title_width : t -> inty_axis_title_width l is the width reserved for the y-axis title, in cells.
y2_axis_width l is the width reserved for the secondary y-axis, in cells.
has_y2 l is true iff a secondary y-axis is active.
Coordinate conversionSource val data_of_px : t -> px :int -> py :int -> (float * float) optiondata_of_px l ~px ~py converts cell coordinates to data coordinates. None if (px, py) is outside the plot region.
Source val px_of_data : t -> x :float -> y :float -> int * intpx_of_data l ~x ~y converts data coordinates to cell coordinates. Values outside the visible range are clamped to the plot boundary.
Category lookupSource val x_category_of_px : t -> px :int -> string option x_category_of_px l ~px is the category at cell column px when the x-axis uses a band scale. None for non-band scales or out-of-range positions.
Source val y_category_of_px : t -> py :int -> string option y_category_of_px l ~py is the category at cell row py when the y-axis uses a band scale.
Source val px_of_x_category : t -> string -> int option px_of_x_category l cat is the centre cell column for category cat. None if cat is not in the scale.
Source val py_of_y_category : t -> string -> int option py_of_y_category l cat is the centre cell row for category cat.
View manipulationSource type axis = [ | `X | `Y | `Both ] The type for axis selectors in zoom/pan operations.
clamp_view l view constrains view to the layout's data domain. Respects the clamp setting on each scale; band scales are unchanged.
zoom_view_around_px l ~view ~axis ~px ~py ~factor zooms view around the data point at cell position (px, py). If the position is outside the plot, zooms around the centre.
pan_view_by_px l ~view ~dx ~dy pans view by (dx, dy) cells. The delta is converted to data units proportional to the current view range and plot size.
Source val plot_center_px : t -> int * intplot_center_px l is the cell coordinates of the plot centre.
zoom_view_around_center l ~view ~axis ~factor zooms view around the plot centre.
See also zoom_view_around_px .
Hit testinghit_test l ~px ~py is the nearest data point to cell position (px, py), or None if (px, py) is outside the plot region or no point is within radius. radius defaults to 3. policy defaults to `Nearest_px.