resolve

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package resolve carries cross-layer scale + axis resolution. The encoder consults it for composite (layer) charts to decide whether each channel resolves once across layers ("shared") or once per layer ("independent"). Defaults match Vega-Lite: x/y shared, color/ size/shape/opacity independent.

Shared-scale type compatibility is checked by Unify in domain.go; incompatible combinations raise PRISM_PLAN_005.

Per design/04-multi-source.md, axis resolution defaults to follow scale resolution: if scale is shared but axis isn't explicitly set, the axis is also shared. The spec can override either independently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Defaults

func Defaults() map[scene.Channel]ChannelResolution

Defaults returns the Vega-Lite-parity default resolution map. The returned map is freshly allocated; callers may mutate.

Defaults:

  • x / y: Scale shared, Axis shared (one set of axes across layers)
  • color / size / shape / opacity: Scale independent, Axis independent (per-layer legends; "axis" is read as "legend" for these channels via design/04-multi-source.md).

func FromSpec

func FromSpec(r *spec.Resolve) map[scene.Channel]ChannelResolution

FromSpec overlays a `spec.Resolve` block on top of Defaults(). When the spec sets `resolve.scale.<ch>` but not `resolve.axis.<ch>`, axis follows scale (design/04-multi-source.md). When only axis is set, scale stays at its default — letting users keep shared scales but independent axes (the "twin-axis with same domain" case).

Unknown / empty mode strings are ignored (defaults win) so a half-filled spec block does not silently flip behaviour.

func Unify

func Unify(layers []LayerDomain) (scene.ScaleType, []any, error)

Unify collapses a set of per-layer domains into one shared scale type + unified domain. Numeric families collapse to numeric min/max; band / ordinal / point collapse to an ordered category union (first-seen across layers, dedup); time collapses to the numeric (epoch_ms) min/max.

Mixed families raise PRISM_PLAN_005 (the channel cannot be shared; caller switches to independent or coerces upstream).

Empty `layers` returns ScaleLinear + an empty domain — the caller should never invoke Unify on an empty set in practice (layers dropped via PRISM_WARN_LAYER_SKIPPED collapse to a single-layer resolve).

Types

type ChannelResolution

type ChannelResolution struct {
	Scale Mode
	Axis  Mode
}

ChannelResolution carries the scale + axis decision for one channel. Axis defaults to follow Scale when the spec leaves it unset.

type LayerDomain

type LayerDomain struct {
	LayerID string
	Channel scene.Channel
	Type    scene.ScaleType
	Values  []any
}

LayerDomain carries one layer's contribution to a channel's domain for the shared-resolution union. Type is the layer's resolved scale family; Values is the raw column data (any).

type Mode

type Mode string

Mode is the per-channel resolution discriminator. Two values only; kept as a typed string for spec-parity with `resolve.scale.<ch>`.

const (
	// ModeShared resolves the channel once across all layers (domain
	// union for numeric/temporal, ordered category union for band/
	// ordinal/point).
	ModeShared Mode = "shared"
	// ModeIndependent resolves the channel once per layer (each layer
	// gets its own scale + axis).
	ModeIndependent Mode = "independent"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL