Visualize.Chart.Schema (Visualize v0.2.25)

Copy Markdown View Source

The design schema as data (spec/14 §14.2).

Every node kind of the design map (spec/14 §1.2) is a list of key specs, each with a type (§1.4), a facet (§1.3), a default, whether it is required and a merge rule (§1.5). The validator, the JSON codec and the introspection a builder needs all derive from these specs, so a key added here reaches every consumer at once (D-58). Which keys are style is keys(:style), never a hand-kept list.

The design-level node kinds live here; the frame's and the marks' tables are in two hidden submodules reached only through this one.

Examples

iex> Visualize.Chart.Schema.key(:mark, :style).facet
:style
iex> Visualize.Chart.Schema.default(:frame, :margin)
%{top: 20, right: 20, bottom: 30, left: 40}
iex> Visualize.Chart.Schema.channels(:line)
%{required: [:x, :y], optional: [:series]}

Summary

Types

What a key is about (spec/14 §1.3).

The heading a style key is shown under in a form (spec/14 §3.1, §14.2).

One key of a node kind.

A node kind of the design map (spec/14 §1.2).

How two fragments combine under a key (spec/14 §1.5).

A type term of spec/14 §1.4.

Functions

The style names every design declares (spec/14 §3.3).

The required and optional channels of a mark type (spec/14 §5.2).

The four column types a source's types may name (spec/14 §2.3, #369).

The default of a key, nil when it has none or is required.

The key specs of a node kind, in the order of its table in spec/14.

The group a key is shown under, or nil (spec/14 §14.2).

The groups a node kind's keys carry, once each, in table order (spec/14 §14.2).

The spec of one key of a node kind, or nil when the node has no such key.

Every {kind, key} pair carrying the facet, over every node kind (spec/14 §1.3).

The keys of one node kind carrying the facet, in table order.

Every node kind of spec/14 §1.2, the design first.

The mark types of spec/14 §5.2, in table order.

The option keys a mark type reads (spec/14 §5.3).

The scale kinds of spec/14 §4.3.

The type a style site takes (spec/14 §3.6): a reference, an inline node, or a list of either.

The required and optional keys of a transform op (spec/14 §5.4).

The transform ops of spec/14 §5.4.

Types

facet()

@type facet() :: :binding | :channel | :geometry | :style | :content

What a key is about (spec/14 §1.3).

group()

@type group() :: :fill | :stroke | :font | :position | :effects

The heading a style key is shown under in a form (spec/14 §3.1, §14.2).

key_spec()

@type key_spec() :: %{
  key: atom(),
  type: type(),
  facet: facet(),
  default: term(),
  required: boolean(),
  merge: merge(),
  range: {number(), number(), number()} | nil,
  group: group() | nil
}

One key of a node kind.

kind()

@type kind() :: atom()

A node kind of the design map (spec/14 §1.2).

merge()

@type merge() :: :concat | :union | :deep | :override

How two fragments combine under a key (spec/14 §1.5).

type()

@type type() :: atom() | tuple()

A type term of spec/14 §1.4.

Functions

builtin_styles()

@spec builtin_styles() :: [atom(), ...]

The style names every design declares (spec/14 §3.3).

channels(type)

@spec channels(atom()) :: %{required: [atom()], optional: [atom()]}

The required and optional channels of a mark type (spec/14 §5.2).

column_types()

@spec column_types() :: [atom(), ...]

The four column types a source's types may name (spec/14 §2.3, #369).

default(kind, key)

@spec default(kind(), atom()) :: term()

The default of a key, nil when it has none or is required.

describe(kind)

@spec describe(kind()) :: [key_spec(), ...]

The key specs of a node kind, in the order of its table in spec/14.

group(kind, key)

@spec group(atom(), atom()) :: group() | nil

The group a key is shown under, or nil (spec/14 §14.2).

iex> Visualize.Chart.Schema.group(:style, :stroke_linecap)
:stroke

iex> Visualize.Chart.Schema.group(:style, :extends)
nil

groups(kind)

@spec groups(atom()) :: [group()]

The groups a node kind's keys carry, once each, in table order (spec/14 §14.2).

iex> Visualize.Chart.Schema.groups(:style)
[:fill, :stroke, :font, :position, :effects]

iex> Visualize.Chart.Schema.groups(:mark)
[]

key(kind, key)

@spec key(kind(), atom()) :: key_spec() | nil

The spec of one key of a node kind, or nil when the node has no such key.

keys(facet)

@spec keys(facet()) :: [{kind(), atom()}]

Every {kind, key} pair carrying the facet, over every node kind (spec/14 §1.3).

keys(kind, facet)

@spec keys(kind(), facet()) :: [atom()]

The keys of one node kind carrying the facet, in table order.

kinds()

@spec kinds() :: [kind(), ...]

Every node kind of spec/14 §1.2, the design first.

mark_types()

@spec mark_types() :: [atom(), ...]

The mark types of spec/14 §5.2, in table order.

options(type)

@spec options(atom()) :: [atom()]

The option keys a mark type reads (spec/14 §5.3).

scale_kinds()

@spec scale_kinds() :: [atom(), ...]

The scale kinds of spec/14 §4.3.

style_stack()

@spec style_stack() :: type()

The type a style site takes (spec/14 §3.6): a reference, an inline node, or a list of either.

Written once because five keys share it — mark.style, label.style, mark_label.style, axis.style and legend.style — and a sixth would otherwise be a sixth copy.

iex> {:one_of, alts} = Visualize.Chart.Schema.style_stack()
iex> {:ref, :style} in alts
true

transform_keys(op)

@spec transform_keys(atom()) :: %{required: [atom()], optional: [atom()]}

The required and optional keys of a transform op (spec/14 §5.4).

transform_ops()

@spec transform_ops() :: [atom(), ...]

The transform ops of spec/14 §5.4.