Coordinates
Data coordinates are distinct from layout lengths. Numeric graph points are data;
width, height, stroke widths, and other lengths use the ordinary units.
Unit strings in point coordinates are local lengths: "50%" uses half the
corresponding drawing dimension, and "10px" is a pixel offset. They do not pass
through data-axis mapping. Bare numeric points keep their data meaning.
For placing elements with pos and anchor, start with Positioning.
infer_coordinates(children, options) returns an immutable
{xlim,ylim,flip_x,flip_y} record. An optional core Projection maps coordinate
records before the axis mapping. map_point(point, coordinates, size) maps to
pixels, returning null if the projection omits the point. unmap_point reverses
linear mapping; custom projections and zero-sized frames cannot be inverted.
point_bounds, merge_bounds, and data_bounds(element) support inference.
Source mapping accepts numeric records with any named dimensions, or [x,y]
tuples. Cartesian bounds and inverse mapping require {x,y} or [x,y].
Non-null mapping results have named {x,y} coordinates. See Point values
for the shared input convention and examples using zip and length tuples.
A custom element reports bounds with a static method:
These helpers and types are exports from gum-jsx-core. The factory form
define_element also accepts data_bounds in its fourth options argument.
See Custom elements for both forms and inherited hooks.
Ordinary containers contribute descendant bounds. A data_bounds callback is a boundary: returning null excludes the subtree. Graph and Plot use this to isolate their internal data.
LayoutQuery and LayoutContext expose coordinates. query.child accepts a fifth context argument: {coordinates} establishes a context, {coordinates:null} clears it, and omission inherits it. Coordinates participate in layout-cache identity. query.prepare must stay independent of coordinates, requests, and references. The engine transports context; inference and mapping remain element policies.
Use coordinate_point(value, size, query.measure, query.coordinates) when a
custom element accepts either numeric data records or tagged local Cartesian lengths.
Mapping complete records supports polar and geographic projections; mapping x and y
separately with coordinate_length cannot do that. See Projections
for the callback contract and examples.