axes

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTickFormatter

func DefaultTickFormatter(value interface{}) string

DefaultTickFormatter provides basic formatting for tick labels

func SITickFormatter

func SITickFormatter(value interface{}) string

SITickFormatter formats numbers with SI prefixes (k, M, G, etc.)

Types

type Axis

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

Axis represents a visualization axis with tick marks and labels. Works with any scale type (linear, log, time, band, etc.) to generate appropriate tick positions and labels.

Example:

scale := scales.NewLinearScale([2]float64{0, 100}, [2]units.Length{units.Px(0), units.Px(500)})
axis := NewAxis(scale, AxisOrientationBottom)
axis.TickCount(10).Title("Temperature (°C)")

func NewAxis

func NewAxis(scale scales.Scale, orientation AxisOrientation) *Axis

NewAxis creates a new axis with the given scale and orientation

func (*Axis) Grid

func (a *Axis) Grid(length units.Length) *Axis

Grid enables grid lines with the specified length

func (*Axis) Orientation

func (a *Axis) Orientation() AxisOrientation

Orientation returns the axis orientation

func (*Axis) Render

func (a *Axis) Render(opts RenderOptions) string

Render generates SVG markup for this axis

func (*Axis) Scale

func (a *Axis) Scale() scales.Scale

Scale returns the axis scale

func (*Axis) String

func (a *Axis) String(opts RenderOptions) string

String generates the complete SVG string for this axis

func (*Axis) TickCount

func (a *Axis) TickCount(count int) *Axis

TickCount sets the desired number of ticks

func (*Axis) TickFormat

func (a *Axis) TickFormat(formatter TickFormatFunc) *Axis

TickFormat sets the tick label formatter

func (*Axis) TickPadding

func (a *Axis) TickPadding(padding units.Length) *Axis

TickPadding sets the spacing between ticks and labels

func (*Axis) TickSize

func (a *Axis) TickSize(size units.Length) *Axis

TickSize sets the length of tick marks

func (*Axis) Ticks

func (a *Axis) Ticks() []Tick

Ticks generates tick marks for this axis

func (*Axis) Title

func (a *Axis) Title(title string) *Axis

Title sets the axis title

type AxisOrientation

type AxisOrientation int

AxisOrientation specifies where the axis is positioned

const (
	AxisOrientationTop AxisOrientation = iota
	AxisOrientationBottom
	AxisOrientationLeft
	AxisOrientationRight
)

func (AxisOrientation) IsHorizontal

func (o AxisOrientation) IsHorizontal() bool

IsHorizontal returns true if the axis is horizontal

func (AxisOrientation) IsVertical

func (o AxisOrientation) IsVertical() bool

IsVertical returns true if the axis is vertical

func (AxisOrientation) String

func (o AxisOrientation) String() string

String returns the orientation name

type AxisStyle

type AxisStyle struct {
	StrokeColor     string
	StrokeWidth     float64
	TextColor       string
	FontSize        float64
	FontFamily      string
	GridStrokeColor string
	GridStrokeWidth float64
	GridDashArray   string
	TitleFontSize   float64
	TitleFontWeight string
	TextOverflow    TextOverflow // How to handle long labels
}

AxisStyle contains styling options for axis rendering

func DefaultAxisStyle

func DefaultAxisStyle() AxisStyle

DefaultAxisStyle returns the default axis styling

type RenderOptions

type RenderOptions struct {
	Style    AxisStyle
	Position units.Length // Position perpendicular to axis (e.g., y-position for horizontal axis)
}

RenderOptions contains options for rendering an axis

func DefaultRenderOptions

func DefaultRenderOptions() RenderOptions

DefaultRenderOptions returns default render options

type TextOverflow

type TextOverflow int

TextOverflow defines how long text should be handled

const (
	// TextOverflowEllipsis truncates text with "..." when it's too long
	TextOverflowEllipsis TextOverflow = iota
	// TextOverflowWrap wraps text onto multiple lines (future enhancement)
	TextOverflowWrap
	// TextOverflowClip clips text without ellipsis
	TextOverflowClip
)

type Tick

type Tick struct {
	Value    interface{}  // Domain value
	Position units.Length // Pixel position along axis
	Label    string       // Formatted label text
}

Tick represents a single axis tick with position and label

type TickFormatFunc

type TickFormatFunc func(value interface{}) string

TickFormatFunc formats tick values into labels

func NumberTickFormatter

func NumberTickFormatter(precision int) TickFormatFunc

NumberTickFormatter creates a formatter for numbers with custom precision

func TimeTickFormatter

func TimeTickFormatter(format string) TickFormatFunc

TimeTickFormatter creates a formatter for time values with custom format

Jump to

Keyboard shortcuts

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