Documentation
¶
Index ¶
- func DefaultTickFormatter(value interface{}) string
- func SITickFormatter(value interface{}) string
- type Axis
- func (a *Axis) Grid(length units.Length) *Axis
- func (a *Axis) Orientation() AxisOrientation
- func (a *Axis) Render(opts RenderOptions) string
- func (a *Axis) Scale() scales.Scale
- func (a *Axis) String(opts RenderOptions) string
- func (a *Axis) TickCount(count int) *Axis
- func (a *Axis) TickFormat(formatter TickFormatFunc) *Axis
- func (a *Axis) TickPadding(padding units.Length) *Axis
- func (a *Axis) TickSize(size units.Length) *Axis
- func (a *Axis) Ticks() []Tick
- func (a *Axis) Title(title string) *Axis
- type AxisOrientation
- type AxisStyle
- type RenderOptions
- type TextOverflow
- type Tick
- type TickFormatFunc
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) 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) String ¶
func (a *Axis) String(opts RenderOptions) string
String generates the complete SVG string for this axis
func (*Axis) TickFormat ¶
func (a *Axis) TickFormat(formatter TickFormatFunc) *Axis
TickFormat sets the tick label formatter
func (*Axis) TickPadding ¶
TickPadding sets the spacing between ticks and labels
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