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 ¶
- Variables
- func FormatNumber(v float64) string
- func NiceSequence(lo, hi float64, n int) []float64
- type AlphaScale
- type BinnedOpt
- type BinnedScale
- func (s *BinnedScale) Bounds() (float64, float64)
- func (s *BinnedScale) Format(v float64) string
- func (s *BinnedScale) Inverse(v float64) float64
- func (s *BinnedScale) Map(v float64) float64
- func (s *BinnedScale) SetBounds(mn, mx float64)
- func (s *BinnedScale) String() string
- func (s *BinnedScale) Ticks(_ int) []float64
- func (s *BinnedScale) Train(col dataset.AnyColumn) error
- type BoundsSetter
- type ConfiguredScale
- func (c *ConfiguredScale) Bounds() (float64, float64)
- func (c *ConfiguredScale) Expand() (mult, add float64)
- func (c *ConfiguredScale) Format(v float64) string
- func (c *ConfiguredScale) HasExpand() bool
- func (c *ConfiguredScale) Inner() Scale
- func (c *ConfiguredScale) Inverse(v float64) float64
- func (c *ConfiguredScale) Map(v float64) float64
- func (c *ConfiguredScale) MinorTicks() []float64
- func (c *ConfiguredScale) SetBounds(mn, mx float64)
- func (c *ConfiguredScale) String() string
- func (c *ConfiguredScale) Ticks(n int) []float64
- func (c *ConfiguredScale) Train(col dataset.AnyColumn) error
- type DateTimeScale
- func (s *DateTimeScale) Bounds() (float64, float64)
- func (s *DateTimeScale) Format(v float64) string
- func (s *DateTimeScale) Inverse(v float64) float64
- func (s *DateTimeScale) Map(v float64) float64
- func (s *DateTimeScale) SetBounds(mn, mx float64)
- func (s *DateTimeScale) String() string
- func (s *DateTimeScale) Ticks(n int) []float64
- func (s *DateTimeScale) Train(col dataset.AnyColumn) error
- type DateUnit
- type DiscreteScale
- func (s *DiscreteScale) Bounds() (float64, float64)
- func (s *DiscreteScale) Categories() []string
- func (s *DiscreteScale) Format(v float64) string
- func (s *DiscreteScale) Inverse(v float64) float64
- func (s *DiscreteScale) Map(v float64) float64
- func (s *DiscreteScale) MapCategory(label string) float64
- func (s *DiscreteScale) SetBounds(_, _ float64)
- func (s *DiscreteScale) String() string
- func (s *DiscreteScale) Ticks(_ int) []float64
- func (s *DiscreteScale) Train(col dataset.AnyColumn) error
- func (s *DiscreteScale) TrainValues(labels []string)
- type Expander
- type IdentityScale
- func (s *IdentityScale) Bounds() (float64, float64)
- func (s *IdentityScale) Format(v float64) string
- func (s *IdentityScale) Inverse(v float64) float64
- func (s *IdentityScale) Map(v float64) float64
- func (s *IdentityScale) MapValue(v float64) float64
- func (s *IdentityScale) SetBounds(mn, mx float64)
- func (s *IdentityScale) String() string
- func (s *IdentityScale) Ticks(n int) []float64
- func (s *IdentityScale) Train(col dataset.AnyColumn) error
- type LinearScale
- func (s *LinearScale) Bounds() (float64, float64)
- func (s *LinearScale) Format(v float64) string
- func (s *LinearScale) Inverse(v float64) float64
- func (s *LinearScale) Map(v float64) float64
- func (s *LinearScale) SetBounds(mn, mx float64)
- func (s *LinearScale) String() string
- func (s *LinearScale) Ticks(n int) []float64
- func (s *LinearScale) Train(col dataset.AnyColumn) error
- type LinetypeScale
- type Manager
- type MinorTicker
- type OOBPolicy
- type Opt
- func WithBinBreaks(edges []float64) Opt
- func WithBins(n int) Opt
- func WithBreaks(breaks []float64) Opt
- func WithClipBounds(lo, hi float64) Opt
- func WithExpand(mult, add float64) Opt
- func WithFormatter(fn func(float64) string) Opt
- func WithLabels(labels []string) Opt
- func WithMinorBreaks(breaks []float64) Opt
- func WithOOB(policy OOBPolicy) Opt
- type Scale
- type ShapeScale
- type SizeMode
- type SizeScale
- func (s *SizeScale) Bounds() (float64, float64)
- func (s *SizeScale) Format(v float64) string
- func (s *SizeScale) Inverse(v float64) float64
- func (s *SizeScale) Map(v float64) float64
- func (s *SizeScale) MapValue(v float64) float64
- func (s *SizeScale) Mode() SizeMode
- func (s *SizeScale) Range() (float64, float64)
- func (s *SizeScale) SetBounds(mn, mx float64)
- func (s *SizeScale) String() string
- func (s *SizeScale) Ticks(n int) []float64
- func (s *SizeScale) Train(col dataset.AnyColumn) error
- type Type
- type ValueMapper
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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
BinnedBins sets an explicit number of bins.
func BinnedBreaks ¶ added in v0.0.6
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
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.
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:
- WithLabels (positional match against Ticks)
- WithFormatter
- 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.
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.
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
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.
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) Ticks ¶
func (s *LinearScale) Ticks(n int) []float64
Ticks generates n nicely spaced tick positions.
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".
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds trained scales for all aesthetic channels.
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
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
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
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
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
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
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
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
WithMinorBreaks sets explicit minor tick positions (data space). Minor ticks are used to draw minor grid lines between major ticks.
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
Configure wraps an existing Scale with the given options. If no options are provided the inner scale is returned unchanged.
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
NewDateTimeIn returns a DateTime scale using the specified timezone.
func NewReverse ¶
func NewReverse() Scale
NewReverse returns a scale that inverts the axis direction.
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 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".
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 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) MapValue ¶ added in v0.0.8
MapValue maps a data value to its actual pixel radius, clamped to the configured range.
type ValueMapper ¶ added in v0.0.8
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.