scale

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package scale provides scale transformations that map data values to visual aesthetic values. Scales control axis ranges, color mappings, size mappings, and produce the guides (axes and legends) that make plots interpretable.

Continuous scales map a numeric domain [min, max] to a visual range. Discrete scales map categorical values to a set of visual values.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedScale is returned for unsupported scale types.
	ErrUnsupportedScale = errors.New("scale: unsupported scale type")

	// ErrInvalidBreak is returned for invalid scale breaks.
	ErrInvalidBreak = errors.New("scale: invalid break value")
)

Sentinel errors for the scale package.

View Source
var Q = []float64{1, 5, 2, 2.5, 4, 3}

Q is the preference-ordered set of "nice" step multipliers. Order encodes simplicity: earlier values are preferred.

Functions

func FormatNumber

func FormatNumber(v float64) string

FormatNumber formats a tick value for display. Integers are shown without decimals; floats use compact notation.

Integers in [1500, 2500] are treated as years and will never receive thousands separators, even if locale-aware formatting is added later.

func NiceSequence

func NiceSequence(lo, hi float64, n int) []float64

NiceSequence produces approximately n optimally placed tick positions between lo and hi using the Talbot-Lin-Hanrahan (2010) extended Wilkinson algorithm. See ticks.go for the full implementation.

Types

type AlphaScale added in v0.0.8

type AlphaScale struct {
	LinearScale
	// contains filtered or unexported fields
}

AlphaScale maps continuous data values to an opacity range [0.1, 1.0] by default.

func NewAlpha added in v0.0.8

func NewAlpha(rangeMin, rangeMax float64) *AlphaScale

NewAlpha returns a new AlphaScale mapping to the specified opacity range.

func NewAlphaDefault added in v0.0.8

func NewAlphaDefault() *AlphaScale

NewAlphaDefault returns a new AlphaScale using the default range [0.1, 1.0].

func (*AlphaScale) MapValue added in v0.0.8

func (s *AlphaScale) MapValue(v float64) float64

MapValue transforms a data value into the actual visual opacity, clamped to the configured range.

func (*AlphaScale) Range added in v0.0.8

func (s *AlphaScale) Range() (float64, float64)

Range returns the configured opacity range.

func (*AlphaScale) String added in v0.0.8

func (s *AlphaScale) String() string

String returns "alpha".

type BinnedOpt added in v0.0.6

type BinnedOpt func(*BinnedScale)

BinnedOpt configures a BinnedScale.

func BinnedBins added in v0.0.6

func BinnedBins(n int) BinnedOpt

BinnedBins sets an explicit number of bins.

func BinnedBreaks added in v0.0.6

func BinnedBreaks(edges []float64) BinnedOpt

BinnedBreaks sets explicit bin edges, overriding automatic computation. The slice must be sorted and have at least 2 elements.

func BinnedMethod added in v0.0.6

func BinnedMethod(m string) BinnedOpt

BinnedMethod sets the bin-count selection method. Supported: "sturges" (default), "scott", "fd", "sqrt".

type BinnedScale added in v0.0.6

type BinnedScale struct {
	// contains filtered or unexported fields
}

BinnedScale discretizes a continuous domain into equal-width bins. Each bin center becomes a tick position; Format shows the bin range.

This does NOT aggregate data (that's stat.BinX). It relabels the axis so that continuous values are displayed as range categories.

func (*BinnedScale) Bounds added in v0.0.6

func (s *BinnedScale) Bounds() (float64, float64)

Bounds returns the data-space domain [min, max].

func (*BinnedScale) Format added in v0.0.6

func (s *BinnedScale) Format(v float64) string

Format returns the bin range label for a data-space value, e.g. "[40, 50)". The value is matched to its bin via findBin.

func (*BinnedScale) Inverse added in v0.0.6

func (s *BinnedScale) Inverse(v float64) float64

Inverse maps a [0, 1] fraction back to data space.

func (*BinnedScale) Map added in v0.0.6

func (s *BinnedScale) Map(v float64) float64

Map transforms a data value to a [0, 1] fraction using the data domain. Identical to linear normalization through Bounds.

func (*BinnedScale) SetBounds added in v0.0.6

func (s *BinnedScale) SetBounds(mn, mx float64)

SetBounds overrides the domain and recomputes bins.

func (*BinnedScale) String added in v0.0.6

func (s *BinnedScale) String() string

String returns "binned".

func (*BinnedScale) Ticks added in v0.0.6

func (s *BinnedScale) Ticks(_ int) []float64

Ticks returns bin centers in data space.

func (*BinnedScale) Train added in v0.0.6

func (s *BinnedScale) Train(col dataset.AnyColumn) error

Train computes the domain and bin edges from column data.

type BoundsSetter

type BoundsSetter interface {
	SetBounds(mn, mx float64)
}

BoundsSetter is an optional interface for scales that support manual bounds override. Both LinearScale and DiscreteScale implement this.

type ConfiguredScale added in v0.0.2

type ConfiguredScale struct {
	// contains filtered or unexported fields
}

ConfiguredScale is a decorator that wraps any Scale and overrides its behavior based on user-supplied configuration.

func (*ConfiguredScale) Bounds added in v0.0.2

func (c *ConfiguredScale) Bounds() (float64, float64)

Bounds returns the effective domain, applying clip bounds and expand. Priority: clipBounds > expand > inner.Bounds.

func (*ConfiguredScale) Expand added in v0.0.2

func (c *ConfiguredScale) Expand() (mult, add float64)

Expand returns the user-supplied multiplicative and additive expansion parameters.

func (*ConfiguredScale) Format added in v0.0.2

func (c *ConfiguredScale) Format(v float64) string

Format returns the display string for a data value. Priority:

  1. WithLabels (positional match against Ticks)
  2. WithFormatter
  3. inner.Format

func (*ConfiguredScale) HasExpand added in v0.0.2

func (c *ConfiguredScale) HasExpand() bool

HasExpand reports whether the user explicitly set expand parameters.

func (*ConfiguredScale) Inner added in v0.0.2

func (c *ConfiguredScale) Inner() Scale

Inner returns the underlying scale.

func (*ConfiguredScale) Inverse added in v0.0.2

func (c *ConfiguredScale) Inverse(v float64) float64

Inverse maps a [0,1] normalized value back to data space using the effective bounds.

func (*ConfiguredScale) Map added in v0.0.2

func (c *ConfiguredScale) Map(v float64) float64

Map normalizes a data value using the effective bounds (which may include expand and clip adjustments).

func (*ConfiguredScale) MinorTicks added in v0.0.2

func (c *ConfiguredScale) MinorTicks() []float64

MinorTicks returns user-supplied minor break positions if set. Otherwise it auto-generates midpoints between consecutive major ticks.

func (*ConfiguredScale) SetBounds added in v0.0.2

func (c *ConfiguredScale) SetBounds(mn, mx float64)

SetBounds delegates to the inner scale (if it supports it).

func (*ConfiguredScale) String added in v0.0.2

func (c *ConfiguredScale) String() string

String delegates to the inner scale.

func (*ConfiguredScale) Ticks added in v0.0.2

func (c *ConfiguredScale) Ticks(n int) []float64

Ticks returns user-supplied breaks if set, otherwise delegates.

func (*ConfiguredScale) Train added in v0.0.2

func (c *ConfiguredScale) Train(col dataset.AnyColumn) error

Train delegates to the inner scale.

type DateTimeScale added in v0.0.6

type DateTimeScale struct {
	// contains filtered or unexported fields
}

DateTimeScale is a continuous scale for temporal data (timestamps, dates, times-of-day). It auto-detects tick granularity from the data span and formats labels using Go's time package.

Train accepts Column[int64] with DType ∈ {DTypeTimestamp, DTypeDate, DTypeTime}. For DTypeDate columns, values are days since epoch; for DTypeTimestamp/DTypeTime, values are nanoseconds.

func (*DateTimeScale) Bounds added in v0.0.6

func (s *DateTimeScale) Bounds() (float64, float64)

Bounds returns the trained domain [min, max].

func (*DateTimeScale) Format added in v0.0.6

func (s *DateTimeScale) Format(v float64) string

Format converts a temporal value to a display string.

func (*DateTimeScale) Inverse added in v0.0.6

func (s *DateTimeScale) Inverse(v float64) float64

Inverse maps a [0, 1] fraction back to data space.

func (*DateTimeScale) Map added in v0.0.6

func (s *DateTimeScale) Map(v float64) float64

Map transforms a temporal value to a [0, 1] linear fraction.

func (*DateTimeScale) SetBounds added in v0.0.6

func (s *DateTimeScale) SetBounds(mn, mx float64)

SetBounds manually overrides the scale domain.

func (*DateTimeScale) String added in v0.0.6

func (s *DateTimeScale) String() string

String returns "datetime".

func (*DateTimeScale) Ticks added in v0.0.6

func (s *DateTimeScale) Ticks(n int) []float64

Ticks generates approximately n calendar-aligned tick positions.

func (*DateTimeScale) Train added in v0.0.6

func (s *DateTimeScale) Train(col dataset.AnyColumn) error

Train updates the scale domain from temporal column data.

type DateUnit added in v0.0.6

type DateUnit int

DateUnit identifies the granularity for datetime tick generation.

const (
	// DateUnitSecond places ticks at second boundaries.
	DateUnitSecond DateUnit = iota
	// DateUnitMinute places ticks at minute boundaries.
	DateUnitMinute
	// DateUnitHour places ticks at hour boundaries.
	DateUnitHour
	// DateUnitDay places ticks at day boundaries.
	DateUnitDay
	// DateUnitWeek places ticks at week boundaries.
	DateUnitWeek
	// DateUnitMonth places ticks at month boundaries.
	DateUnitMonth
	// DateUnitYear places ticks at year boundaries.
	DateUnitYear
)

type DiscreteScale

type DiscreteScale struct {
	// contains filtered or unexported fields
}

DiscreteScale maps categorical string values to evenly-spaced [0, N-1] positions where N is the number of unique categories.

func Discrete

func Discrete() *DiscreteScale

Discrete returns a discrete (categorical) scale that maps string labels to evenly-spaced numeric positions. Categories are extracted during Train and sorted alphabetically for deterministic ordering.

func (*DiscreteScale) Bounds

func (s *DiscreteScale) Bounds() (float64, float64)

Bounds returns the domain extent with 0.5 padding around categories.

func (*DiscreteScale) Categories

func (s *DiscreteScale) Categories() []string

Categories returns the ordered category labels.

func (*DiscreteScale) Format

func (s *DiscreteScale) Format(v float64) string

Format returns the category label for the nearest index.

func (*DiscreteScale) Inverse

func (s *DiscreteScale) Inverse(v float64) float64

Inverse maps a [0, 1] fraction back to a category index.

func (*DiscreteScale) Map

func (s *DiscreteScale) Map(v float64) float64

Map transforms a category index to a [0, 1] fraction.

func (*DiscreteScale) MapCategory

func (s *DiscreteScale) MapCategory(label string) float64

MapCategory maps a category label to its numeric position.

func (*DiscreteScale) SetBounds

func (s *DiscreteScale) SetBounds(_, _ float64)

SetBounds overrides the domain bounds (used by pipeline padding logic).

func (*DiscreteScale) String

func (s *DiscreteScale) String() string

func (*DiscreteScale) Ticks

func (s *DiscreteScale) Ticks(_ int) []float64

Ticks returns a tick position for each category.

func (*DiscreteScale) Train

func (s *DiscreteScale) Train(col dataset.AnyColumn) error

Train extracts unique string values from the column. If the column is already numeric (e.g. after stat transforms), this is a no-op.

func (*DiscreteScale) TrainValues

func (s *DiscreteScale) TrainValues(labels []string)

TrainValues trains the scale from a pre-built slice of category labels.

type Expander added in v0.0.2

type Expander interface {
	Expand() (mult, add float64)
	HasExpand() bool
}

Expander is an optional interface for scales that carry user-specified expand parameters. The rendering pipeline queries this to decide whether to apply its default 5 % padding or the user's explicit expansion.

type IdentityScale added in v0.0.8

type IdentityScale struct {
	// contains filtered or unexported fields
}

IdentityScale passes raw data values through directly as visual values. Useful when data columns already represent physical pixels, opacities, or colors.

func NewIdentity added in v0.0.8

func NewIdentity() *IdentityScale

NewIdentity returns a new IdentityScale.

func (*IdentityScale) Bounds added in v0.0.8

func (s *IdentityScale) Bounds() (float64, float64)

Bounds returns the scale bounds.

func (*IdentityScale) Format added in v0.0.8

func (s *IdentityScale) Format(v float64) string

Format formats the value.

func (*IdentityScale) Inverse added in v0.0.8

func (s *IdentityScale) Inverse(v float64) float64

Inverse returns the value itself.

func (*IdentityScale) Map added in v0.0.8

func (s *IdentityScale) Map(v float64) float64

Map maps a value to itself (no normalization transformation).

func (*IdentityScale) MapValue added in v0.0.8

func (s *IdentityScale) MapValue(v float64) float64

MapValue returns the value itself.

func (*IdentityScale) SetBounds added in v0.0.8

func (s *IdentityScale) SetBounds(mn, mx float64)

SetBounds manually overrides the scale domain.

func (*IdentityScale) String added in v0.0.8

func (s *IdentityScale) String() string

String returns "identity".

func (*IdentityScale) Ticks added in v0.0.8

func (s *IdentityScale) Ticks(n int) []float64

Ticks returns nicely spaced ticks for the scale domain.

func (*IdentityScale) Train added in v0.0.8

func (s *IdentityScale) Train(col dataset.AnyColumn) error

Train trains the identity scale domain.

type LinearScale

type LinearScale struct {
	// contains filtered or unexported fields
}

LinearScale is a standard linear continuous scale.

func (*LinearScale) Bounds

func (s *LinearScale) Bounds() (float64, float64)

Bounds returns the trained domain [min, max].

func (*LinearScale) Format

func (s *LinearScale) Format(v float64) string

Format converts a data value to a display string.

func (*LinearScale) Inverse

func (s *LinearScale) Inverse(v float64) float64

Inverse maps a [0, 1] fraction back to data space.

func (*LinearScale) Map

func (s *LinearScale) Map(v float64) float64

Map transforms v to a [0, 1] linear fraction of the domain.

func (*LinearScale) SetBounds

func (s *LinearScale) SetBounds(mn, mx float64)

SetBounds manually overrides the scale domain. Used by the rendering pipeline for padding and forcing Y=0.

func (*LinearScale) String

func (s *LinearScale) String() string

String returns "linear".

func (*LinearScale) Ticks

func (s *LinearScale) Ticks(n int) []float64

Ticks generates n nicely spaced tick positions.

func (*LinearScale) Train

func (s *LinearScale) Train(col dataset.AnyColumn) error

Train updates the linear domain from column data.

type LinetypeScale added in v0.0.8

type LinetypeScale struct {
	DiscreteScale
	// contains filtered or unexported fields
}

LinetypeScale maps discrete (categorical) data values to dash patterns.

func NewLinetype added in v0.0.8

func NewLinetype() *LinetypeScale

NewLinetype returns a new LinetypeScale.

func NewLinetypeManual added in v0.0.8

func NewLinetypeManual(m map[string]string) *LinetypeScale

NewLinetypeManual returns a manual LinetypeScale with a custom mapping.

func (*LinetypeScale) DashPattern added in v0.0.8

func (s *LinetypeScale) DashPattern(label string) []float64

DashPattern returns the []float64 dash array for the given category.

func (*LinetypeScale) LinetypeName added in v0.0.8

func (s *LinetypeScale) LinetypeName(label string) string

LinetypeName resolves a category label to a linetype name (e.g. "dashed").

func (*LinetypeScale) String added in v0.0.8

func (s *LinetypeScale) String() string

String returns "linetype".

func (*LinetypeScale) Train added in v0.0.8

func (s *LinetypeScale) Train(col dataset.AnyColumn) error

Train trains the discrete categories.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager holds trained scales for all aesthetic channels.

func NewManager

func NewManager() *Manager

NewManager creates a Manager with default scales.

func (*Manager) Get

func (m *Manager) Get(channel string) Scale

Get retrieves the scale for a channel. Returns a linear scale as default.

func (*Manager) Set

func (m *Manager) Set(channel string, s Scale)

Set registers a scale for an aesthetic channel.

type MinorTicker added in v0.0.2

type MinorTicker interface {
	MinorTicks() []float64
}

MinorTicker is an optional interface for scales that provide minor tick positions between major ticks. Used by the guide system to draw minor grid lines. Implement this by using WithMinorBreaks on a ConfiguredScale.

type OOBPolicy added in v0.0.6

type OOBPolicy int

OOBPolicy defines behavior for data points that fall outside the trained scale domain after normalization.

const (
	// OOBKeep passes out-of-bounds values through unchanged.
	// This is the default behavior — points outside the domain are drawn
	// at their extrapolated positions.
	OOBKeep OOBPolicy = iota

	// OOBCensor replaces out-of-bounds normalized values with NaN,
	// effectively hiding those data points. This matches ggplot2's
	// default oob behavior for continuous scales.
	OOBCensor

	// OOBSquish clamps out-of-bounds normalized values to the [0, 1]
	// range, pinning them to the domain boundary.
	OOBSquish
)

type Opt added in v0.0.2

type Opt func(*ConfiguredScale)

Opt is a functional option that configures a ConfiguredScale.

func WithBinBreaks added in v0.0.6

func WithBinBreaks(edges []float64) Opt

WithBinBreaks sets explicit bin edges for a BinnedScale. The slice must be sorted and have at least 2 elements. Has no effect on other scale types.

ScaleX(scale.Binned, scale.WithBinBreaks([]float64{40, 50, 60, 70, 80, 90, 100}))

func WithBins added in v0.0.6

func WithBins(n int) Opt

WithBins sets the number of bins for a BinnedScale. Has no effect on other scale types.

ScaleX(scale.Binned, scale.WithBins(6))

func WithBreaks added in v0.0.2

func WithBreaks(breaks []float64) Opt

WithBreaks sets explicit tick positions that override the automatic [Scale.Ticks] generation. The values are in data space.

func WithClipBounds added in v0.0.2

func WithClipBounds(lo, hi float64) Opt

WithClipBounds sets a visible-window clip range that is independent of the data domain. Data points outside this range are still present in the dataset (no filtering), but the axis shows only [min, max]. Use math.NaN() for either bound to leave it auto-detected.

func WithExpand added in v0.0.2

func WithExpand(mult, add float64) Opt

WithExpand controls the padding added to the scale domain after training. mult is a multiplicative fraction of the data range added to each side (e.g. 0.05 = 5 %); add is an absolute amount added to each side in data units. This replaces the renderer's default 5 % expansion for the axis.

ggplot2 equivalent: scale_x_continuous(expand = expansion(mult, add))

func WithFormatter added in v0.0.2

func WithFormatter(fn func(float64) string) Opt

WithFormatter sets a custom formatting function that replaces the inner scale's [Scale.Format] for every tick value. When both WithFormatter and WithLabels are set, WithLabels takes priority for positions that have a matching index.

func WithLabels added in v0.0.2

func WithLabels(labels []string) Opt

WithLabels sets explicit tick labels corresponding to the positions produced by WithBreaks (same index order). If len(labels) < len(breaks), excess ticks use the inner scale's Format. If WithBreaks is not set, labels are matched to auto-generated ticks positionally.

func WithMinorBreaks added in v0.0.2

func WithMinorBreaks(breaks []float64) Opt

WithMinorBreaks sets explicit minor tick positions (data space). Minor ticks are used to draw minor grid lines between major ticks.

func WithOOB added in v0.0.6

func WithOOB(policy OOBPolicy) Opt

WithOOB sets the out-of-bounds policy for normalized values. See OOBKeep, OOBCensor, OOBSquish.

type Scale

type Scale interface {
	// Train updates the scale's domain from the given column data.
	Train(col dataset.AnyColumn) error

	// Map transforms a raw value to the [0,1] normalized scale.
	Map(v float64) float64

	// Inverse maps a [0,1] normalized value back to data space.
	Inverse(v float64) float64

	// Ticks generates n nicely spaced tick positions in data space.
	Ticks(n int) []float64

	// Format converts a data value to a display string.
	Format(v float64) string

	// Bounds returns the trained domain [min, max].
	Bounds() (float64, float64)

	// String returns a description.
	String() string
}

Scale defines the interface for all scale types.

func Configure added in v0.0.2

func Configure(inner Scale, opts ...Opt) Scale

Configure wraps an existing Scale with the given options. If no options are provided the inner scale is returned unchanged.

func NewBinned added in v0.0.6

func NewBinned(opts ...BinnedOpt) Scale

NewBinned returns a binned scale with the given options.

func NewDateTime added in v0.0.6

func NewDateTime() Scale

NewDateTime returns a DateTime scale using the local timezone.

func NewDateTimeIn added in v0.0.6

func NewDateTimeIn(loc *time.Location) Scale

NewDateTimeIn returns a DateTime scale using the specified timezone.

func NewLinear

func NewLinear() Scale

NewLinear returns a standard linear scale.

func NewLog10

func NewLog10() Scale

NewLog10 returns a base-10 logarithmic scale.

func NewReverse

func NewReverse() Scale

NewReverse returns a scale that inverts the axis direction.

func NewSqrt

func NewSqrt() Scale

NewSqrt returns a square-root scale.

func Resolve

func Resolve(t Type) (Scale, error)

Resolve returns a Scale for the given type. Returns an error for unknown types.

type ShapeScale added in v0.0.8

type ShapeScale struct {
	DiscreteScale
	// contains filtered or unexported fields
}

ShapeScale maps discrete (categorical) data values to shape names.

func NewShape added in v0.0.8

func NewShape() *ShapeScale

NewShape returns a new ShapeScale.

func NewShapeManual added in v0.0.8

func NewShapeManual(m map[string]string) *ShapeScale

NewShapeManual returns a manual ShapeScale with custom mapping.

func (*ShapeScale) ShapeName added in v0.0.8

func (s *ShapeScale) ShapeName(label string) string

ShapeName maps a category label to a shape name (e.g. "circle", "square").

func (*ShapeScale) String added in v0.0.8

func (s *ShapeScale) String() string

String returns "shape".

func (*ShapeScale) Train added in v0.0.8

func (s *ShapeScale) Train(col dataset.AnyColumn) error

Train trains the discrete categories.

type SizeMode added in v0.0.8

type SizeMode string

SizeMode controls how values map to sizes.

const (
	// SizeModeLinear maps values linearly to radius.
	SizeModeLinear SizeMode = "linear"
	// SizeModeArea maps values to area (radius is proportional to sqrt(value)).
	SizeModeArea SizeMode = "area"
	// SizeModeRadius maps values to radius direct proportionally (value of 0 maps to 0).
	SizeModeRadius SizeMode = "radius"
)

type SizeScale added in v0.0.8

type SizeScale struct {
	// contains filtered or unexported fields
}

SizeScale maps continuous data values to a point-radius range.

func NewSize added in v0.0.8

func NewSize(rangeMin, rangeMax float64) *SizeScale

NewSize returns a new SizeScale with the specified radius range.

func NewSizeArea added in v0.0.8

func NewSizeArea() *SizeScale

NewSizeArea returns a new SizeScale configured for area-proportional mapping.

func NewSizeDefault added in v0.0.8

func NewSizeDefault() *SizeScale

NewSizeDefault returns a new linear SizeScale using the default range [1.0, 6.0].

func (*SizeScale) Bounds added in v0.0.8

func (s *SizeScale) Bounds() (float64, float64)

Bounds returns the scale bounds.

func (*SizeScale) Format added in v0.0.8

func (s *SizeScale) Format(v float64) string

Format formats values as strings.

func (*SizeScale) Inverse added in v0.0.8

func (s *SizeScale) Inverse(v float64) float64

Inverse maps a normalized fraction back to data space.

func (*SizeScale) Map added in v0.0.8

func (s *SizeScale) Map(v float64) float64

Map maps a value v to a normalized fraction in [0, 1].

func (*SizeScale) MapValue added in v0.0.8

func (s *SizeScale) MapValue(v float64) float64

MapValue maps a data value to its actual pixel radius, clamped to the configured range.

func (*SizeScale) Mode added in v0.0.8

func (s *SizeScale) Mode() SizeMode

Mode returns the sizing mode (linear, area, or radius).

func (*SizeScale) Range added in v0.0.8

func (s *SizeScale) Range() (float64, float64)

Range returns the scale range.

func (*SizeScale) SetBounds added in v0.0.8

func (s *SizeScale) SetBounds(mn, mx float64)

SetBounds manually overrides scale bounds.

func (*SizeScale) String added in v0.0.8

func (s *SizeScale) String() string

String returns "size".

func (*SizeScale) Ticks added in v0.0.8

func (s *SizeScale) Ticks(n int) []float64

Ticks generates nice tick values.

func (*SizeScale) Train added in v0.0.8

func (s *SizeScale) Train(col dataset.AnyColumn) error

Train trains the scale's domain on a data column.

type Type

type Type string

Type identifies a scale transformation.

const (
	Linear   Type = "linear"
	Log10    Type = "log10"
	Sqrt     Type = "sqrt"
	Reverse  Type = "reverse"
	DateTime Type = "datetime"
	Binned   Type = "binned"
)

Linear is the standard linear scale type.

type ValueMapper added in v0.0.8

type ValueMapper interface {
	MapValue(v float64) float64
}

ValueMapper is an optional interface for scales that provide a direct data-to-visual mapping (e.g., size in pixels, opacity). Drawing code prefers MapValue over Map when available because Map returns a normalized [0, 1] fraction that still needs range interpolation.

Jump to

Keyboard shortcuts

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