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.

Source

Box::equal

fn Box::equal(Box, Box) -> Bool

Source

Box::not_equal

fn Box::not_equal(x : Box, y : Box) -> Bool

Source

Box::to_repr

fn Box::to_repr(Box) -> @moonbitlang/core/debug.Repr

Source

Connector

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.

Source

Connector::equal

fn Connector::equal(Connector, Connector) -> Bool

Source

Connector::not_equal

fn Connector::not_equal(x : Connector, y : Connector) -> Bool

Source

Connector::path

fn Connector::path(self : Connector) -> String

The SVG path data of the connector.

Source

Connector::samples

fn Connector::samples(self : Connector, count? : Int) -> Array[Point]

Sample points along the connector, for checks.

Source

Connector::to_repr

fn Connector::to_repr(Connector) -> @moonbitlang/core/debug.Repr

Source

Finding

pub struct Finding {
  rule : Rule
  identities : ReadOnlyArray[String]
  message : String
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Finding::equal

fn Finding::equal(Finding, Finding) -> Bool

Source

Finding::not_equal

fn Finding::not_equal(x : Finding, y : Finding) -> Bool

Source

Finding::to_repr

fn Finding::to_repr(Finding) -> @moonbitlang/core/debug.Repr

Source

Geometry

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.

Source

Geometry::equal

fn Geometry::equal(Geometry, Geometry) -> Bool

Source

Geometry::not_equal

fn Geometry::not_equal(x : Geometry, y : Geometry) -> Bool

Source

Geometry::to_repr

fn Geometry::to_repr(Geometry) -> @moonbitlang/core/debug.Repr

Source

Ink

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.

Source

Ink::color

fn Ink::color(self : Ink, palette : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.Color

Source

Ink::equal

fn Ink::equal(Ink, Ink) -> Bool

Source

Ink::not_equal

fn Ink::not_equal(x : Ink, y : Ink) -> Bool

Source

Ink::to_repr

fn Ink::to_repr(Ink) -> @moonbitlang/core/debug.Repr

Source

Ink::token

fn Ink::token(self : Ink) -> String

The theme token of the ink: text, muted or a family ink.

Source

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.

Source

Kind::equal

fn Kind::equal(Kind, Kind) -> Bool

Source

Kind::name

fn Kind::name(self : Kind) -> String

Source

Kind::not_equal

fn Kind::not_equal(x : Kind, y : Kind) -> Bool

Source

Kind::to_repr

fn Kind::to_repr(Kind) -> @moonbitlang/core/debug.Repr

Source

Label

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.

Source

Label::equal

fn Label::equal(Label, Label) -> Bool

Source

Label::not_equal

fn Label::not_equal(x : Label, y : Label) -> Bool

Source

Label::to_repr

fn Label::to_repr(Label) -> @moonbitlang/core/debug.Repr

Source

Limits

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.

Source

Limits::equal

fn Limits::equal(Limits, Limits) -> Bool

Source

Limits::new

fn Limits::new(nodes? : Int, depth? : Int, work? : Int, width? : Int, output_units? : Int, minimum_approach? : Double) -> Limits

Source

Limits::not_equal

fn Limits::not_equal(x : Limits, y : Limits) -> Bool

Source

Limits::to_repr

fn Limits::to_repr(Limits) -> @moonbitlang/core/debug.Repr

Source

Limits::with_minimum_approach

fn Limits::with_minimum_approach(self : Limits, minimum_approach : Double) -> Limits

Source

Point

pub(all) struct Point {
  x : Double
  y : Double
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Point::equal

fn Point::equal(Point, Point) -> Bool

Source

Point::not_equal

fn Point::not_equal(x : Point, y : Point) -> Bool

Source

Point::to_repr

fn Point::to_repr(Point) -> @moonbitlang/core/debug.Repr

Source

Rect

pub(all) struct Rect {
  x : Double
  y : Double
  width : Double
  height : Double
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Rect::bottom

fn Rect::bottom(self : Rect) -> Double

Source

Rect::contains

fn Rect::contains(self : Rect, other : Rect, tolerance? : Double) -> Bool

Source

Rect::equal

fn Rect::equal(Rect, Rect) -> Bool

Source

Rect::not_equal

fn Rect::not_equal(x : Rect, y : Rect) -> Bool

Source

Rect::overlaps

fn Rect::overlaps(self : Rect, other : Rect) -> Bool

Source

Rect::right

fn Rect::right(self : Rect) -> Double

Source

Rect::to_repr

fn Rect::to_repr(Rect) -> @moonbitlang/core/debug.Repr

Source

Result

pub struct Result {
  geometry : Geometry?
  diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}

Source

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.

Source

Row::equal

fn Row::equal(Row, Row) -> Bool

Source

Row::not_equal

fn Row::not_equal(x : Row, y : Row) -> Bool

Source

Row::to_repr

fn Row::to_repr(Row) -> @moonbitlang/core/debug.Repr

Source

Rule

pub(all) enum Rule {
  Overlap
  Fit
  Size
  Contrast
  Containment
  Endpoint
  Limit
} derive(Eq, @moonbitlang/core/debug.Debug)

The rule that a legibility finding breaks.

Source

Rule::equal

fn Rule::equal(Rule, Rule) -> Bool

Source

Rule::not_equal

fn Rule::not_equal(x : Rule, y : Rule) -> Bool

Source

Rule::to_repr

fn Rule::to_repr(Rule) -> @moonbitlang/core/debug.Repr

Source

Values

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.

Source

display_text

fn display_text(value : @moonrockz/diagrams/data-tree.Value) -> String

The 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.

Source

highlight_background

fn highlight_background(palette : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.Color

The background of a highlighted row: the cloud family fill over the box fill.

Source

ink_of

fn ink_of(kind : Kind) -> Ink

The ink of a scalar or container value.

Source

kind_of

fn kind_of(value : @moonrockz/diagrams/data-tree.Value) -> Kind

Source

label_clearance

let label_clearance : Double

The smallest space between a label and the edge of its row.

Source

layout

fn layout(tree : @moonrockz/diagrams/data-tree.DataTree, limits? : Limits) -> Result

Measured 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.

Source

palette

fn palette(p : @moonrockz/diagrams-svg/theme.Palette) -> @moonrockz/diagrams-svg/theme.Palette

The 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.

Source

svg_number

fn svg_number(value : Double) -> String

Canonical coordinates have at most three fractional digits and never use exponent notation.

Source

text_width

fn text_width(line : String, size? : Int, weight? : Int) -> Double

The measured width of one line of text.

Source