moonrockz/diagrams-svg/data-tree-layout
Types
Box
pub struct Box {
node : String
kind : Kind
box : Rect
divider : Double?
rows : ReadOnlyArray[Row]
label : Label?
highlighted : Bool
depth : Int
} derive(Eq, @moonbitlang/core/debug.Debug)One box: a container with its rows, or a scalar root.
Box::equal
fn Box::equal(Box, Box) -> BoolBox::not_equal
fn Box::not_equal(x : Box, y : Box) -> BoolBox::to_repr
fn Box::to_repr(Box) -> @moonbitlang/core/debug.ReprConnector
pub struct Connector {
entry : String
source : String
target : String
points : ReadOnlyArray[Point]
} derive(Eq, @moonbitlang/core/debug.Debug)A drawn connector from a row to the box of its nested container. The points are the start, the end of the straight part, two curve controls and the end.
Connector::equal
fn Connector::equal(Connector, Connector) -> BoolConnector::not_equal
fn Connector::not_equal(x : Connector, y : Connector) -> BoolConnector::path
fn Connector::path(self : Connector) -> StringThe SVG path data of the connector.
Connector::samples
fn Connector::samples(self : Connector, count? : Int) -> Array[Point]Sample points along the connector, for checks.
Connector::to_repr
fn Connector::to_repr(Connector) -> @moonbitlang/core/debug.ReprFinding
pub struct Finding {
rule : Rule
identities : ReadOnlyArray[String]
message : String
} derive(Eq, @moonbitlang/core/debug.Debug)Finding::equal
fn Finding::equal(Finding, Finding) -> BoolFinding::not_equal
fn Finding::not_equal(x : Finding, y : Finding) -> BoolFinding::to_repr
fn Finding::to_repr(Finding) -> @moonbitlang/core/debug.ReprGeometry
pub struct Geometry {
tree : @moonrockz/diagrams/data-tree.DataTree
width : Int
height : Int
title : Label?
boxes : ReadOnlyArray[Box]
connectors : ReadOnlyArray[Connector]
} derive(Eq, @moonbitlang/core/debug.Debug)The measured geometry of one data view.
Geometry::equal
fn Geometry::equal(Geometry, Geometry) -> BoolGeometry::not_equal
fn Geometry::not_equal(x : Geometry, y : Geometry) -> BoolGeometry::to_repr
fn Geometry::to_repr(Geometry) -> @moonbitlang/core/debug.ReprInk
pub(all) enum Ink {
Key
Index
Text
Number
Boolean
Null
Container
Title
} derive(Eq, @moonbitlang/core/debug.Debug)The ink of a label. Each scalar kind has its own ink.
Ink::color
fn Ink::color(self : Ink, palette : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.ColorInk::equal
fn Ink::equal(Ink, Ink) -> BoolInk::not_equal
fn Ink::not_equal(x : Ink, y : Ink) -> BoolInk::to_repr
fn Ink::to_repr(Ink) -> @moonbitlang/core/debug.ReprInk::token
fn Ink::token(self : Ink) -> StringThe theme token of the ink: text, muted or a family ink.
Kind
pub(all) enum Kind {
Object
Array
String
Number
Boolean
Null
} derive(Eq, @moonbitlang/core/debug.Debug)The kind of a value, as written in the data-type attribute.
Kind::equal
fn Kind::equal(Kind, Kind) -> BoolKind::name
fn Kind::name(self : Kind) -> StringKind::not_equal
fn Kind::not_equal(x : Kind, y : Kind) -> BoolKind::to_repr
fn Kind::to_repr(Kind) -> @moonbitlang/core/debug.ReprLabel
pub struct Label {
lines : ReadOnlyArray[String]
box : Rect
size : Double
weight : Int
ink : Ink
} derive(Eq, @moonbitlang/core/debug.Debug)One measured label. lines are the wrapped lines; with the line breaks
that wrapping replaced, they give the complete text.
Label::equal
fn Label::equal(Label, Label) -> BoolLabel::not_equal
fn Label::not_equal(x : Label, y : Label) -> BoolLabel::to_repr
fn Label::to_repr(Label) -> @moonbitlang/core/debug.ReprLimits
pub struct Limits {
nodes : Int
depth : Int
work : Int
width : Int
output_units : Int
minimum_approach : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Explicit bounds for structured-data layout and painting.
Limits::equal
fn Limits::equal(Limits, Limits) -> BoolLimits::new
fn Limits::new(nodes? : Int, depth? : Int, work? : Int, width? : Int, output_units? : Int, minimum_approach? : Double) -> LimitsLimits::not_equal
fn Limits::not_equal(x : Limits, y : Limits) -> BoolLimits::to_repr
fn Limits::to_repr(Limits) -> @moonbitlang/core/debug.ReprLimits::with_minimum_approach
fn Limits::with_minimum_approach(self : Limits, minimum_approach : Double) -> LimitsPoint
pub(all) struct Point {
x : Double
y : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Point::equal
fn Point::equal(Point, Point) -> BoolPoint::not_equal
fn Point::not_equal(x : Point, y : Point) -> BoolPoint::to_repr
fn Point::to_repr(Point) -> @moonbitlang/core/debug.ReprRect
pub(all) struct Rect {
x : Double
y : Double
width : Double
height : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Rect::bottom
fn Rect::bottom(self : Rect) -> DoubleRect::contains
fn Rect::contains(self : Rect, other : Rect, tolerance? : Double) -> BoolRect::equal
fn Rect::equal(Rect, Rect) -> BoolRect::not_equal
fn Rect::not_equal(x : Rect, y : Rect) -> BoolRect::overlaps
fn Rect::overlaps(self : Rect, other : Rect) -> BoolRect::right
fn Rect::right(self : Rect) -> DoubleRect::to_repr
fn Rect::to_repr(Rect) -> @moonbitlang/core/debug.ReprResult
pub struct Result {
geometry : Geometry?
diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}Row
pub struct Row {
entry : String
node : String
kind : Kind
box : Rect
key : Label?
value : Label?
highlighted : Bool
port : Point?
} derive(Eq, @moonbitlang/core/debug.Debug)One member row of a container box.
Row::equal
fn Row::equal(Row, Row) -> BoolRow::not_equal
fn Row::not_equal(x : Row, y : Row) -> BoolRow::to_repr
fn Row::to_repr(Row) -> @moonbitlang/core/debug.ReprRule
pub(all) enum Rule {
Overlap
Fit
Size
Contrast
Containment
Endpoint
Limit
} derive(Eq, @moonbitlang/core/debug.Debug)The rule that a legibility finding breaks.
Rule::equal
fn Rule::equal(Rule, Rule) -> BoolRule::not_equal
fn Rule::not_equal(x : Rule, y : Rule) -> BoolRule::to_repr
fn Rule::to_repr(Rule) -> @moonbitlang/core/debug.ReprValues
check
fn check(geometry : Geometry, palette : @moonrockz/diagrams-svg/theme.Palette, work_limit? : Int) -> ReadOnlyArray[Finding]Check measured data geometry independently of its painter: row bounds,
label clearance and fit, overlaps, connector attachment and crossings,
text size and the contrast of every label on its background, including
highlighted rows. The check is bounded by work_limit.
display_text
fn display_text(value : @moonrockz/diagrams/data-tree.Value) -> StringThe visible text of a value. Text and number lexemes are exact. Booleans
and null have a mark, so they do not look like text with the same letters.
A row of a nested container shows {…} or […], or {} or [] when the
container is empty.
highlight_background
fn highlight_background(palette : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.ColorThe background of a highlighted row: the cloud family fill over the box fill.
ink_of
fn ink_of(kind : Kind) -> InkThe ink of a scalar or container value.
kind_of
fn kind_of(value : @moonrockz/diagrams/data-tree.Value) -> Kindlabel_clearance
let label_clearance : DoubleThe smallest space between a label and the edge of its row.
layout
fn layout(tree : @moonrockz/diagrams/data-tree.DataTree, limits? : Limits) -> ResultMeasured data geometry. Each container is a box with ordered rows; arrays show the position of each row. A nested container is a separate box in the next column, joined by a connector from its row. Inline scalars stay in their row, with no connector. Empty containers and a scalar root are visible boxes. Layout is iterative and every bound is explicit; exhaustion gives a diagnostic and no geometry.
palette
fn palette(p : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.PaletteThe palette for data views. Each ink that a data label uses gets a shade with 4.5:1 contrast on the box fill and on the highlight background.
svg_number
fn svg_number(value : Double) -> StringCanonical coordinates have at most three fractional digits and never use exponent notation.
text_width
fn text_width(line : String, size? : Int, weight? : Int) -> DoubleThe measured width of one line of text.