Documentation
¶
Index ¶
- type Anchor
- type Annotation
- type AnnotationLayer
- type AnnotationStyle
- type Arrow
- func (a *Arrow) Render(xScale, yScale scales.Scale) string
- func (a *Arrow) WithCurve(curve float64) *Arrow
- func (a *Arrow) WithDoubleHead(double bool) *Arrow
- func (a *Arrow) WithEndHead(show bool) *Arrow
- func (a *Arrow) WithHeadSize(size float64) *Arrow
- func (a *Arrow) WithHeadStyle(style ArrowHeadStyle) *Arrow
- func (a *Arrow) WithStartHead(show bool) *Arrow
- func (a *Arrow) WithStyle(style AnnotationStyle) *Arrow
- type ArrowHeadStyle
- type Baseline
- type CalloutLabel
- type Connector
- type ConnectorStyle
- type Grid
- type MultilineText
- type Orientation
- type Position
- type ReferenceLine
- func (rl *ReferenceLine) Render(xScale, yScale scales.Scale) string
- func (rl *ReferenceLine) WithDashed() *ReferenceLine
- func (rl *ReferenceLine) WithLabel(label string) *ReferenceLine
- func (rl *ReferenceLine) WithLabelAnchor(anchor Anchor) *ReferenceLine
- func (rl *ReferenceLine) WithLabelPosition(pos float64) *ReferenceLine
- func (rl *ReferenceLine) WithStyle(style AnnotationStyle) *ReferenceLine
- type ReferenceRegion
- type TextLabel
- func (tl *TextLabel) Render(xScale, yScale scales.Scale) string
- func (tl *TextLabel) WithAnchor(anchor Anchor) *TextLabel
- func (tl *TextLabel) WithBaseline(baseline Baseline) *TextLabel
- func (tl *TextLabel) WithOffset(x, y float64) *TextLabel
- func (tl *TextLabel) WithRotation(degrees float64) *TextLabel
- func (tl *TextLabel) WithStyle(style AnnotationStyle) *TextLabel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Annotation interface {
// Render renders the annotation to SVG
Render(xScale, yScale scales.Scale) string
}
Annotation represents a visual annotation on a chart
type AnnotationLayer ¶
type AnnotationLayer struct {
Annotations []Annotation
}
AnnotationLayer groups multiple annotations
func NewAnnotationLayer ¶
func NewAnnotationLayer() *AnnotationLayer
NewAnnotationLayer creates a new annotation layer
func (*AnnotationLayer) Add ¶
func (al *AnnotationLayer) Add(annotation Annotation) *AnnotationLayer
Add adds an annotation to the layer
type AnnotationStyle ¶
type AnnotationStyle struct {
Stroke string
StrokeWidth float64
Fill string
Opacity float64
StrokeDash string
FontSize units.Length
FontFamily string
FontWeight string
TextAnchor Anchor
TextBaseline Baseline
Color string
}
AnnotationStyle contains common styling for annotations
func DefaultAnnotationStyle ¶
func DefaultAnnotationStyle() AnnotationStyle
DefaultAnnotationStyle returns the default annotation style
type Arrow ¶
type Arrow struct {
// Start and end positions in data coordinates (if PositionData)
X1, Y1, X2, Y2 interface{}
// Pixel positions (if PositionPixel)
PxX1, PxY1, PxX2, PxY2 float64
// Positioning mode
Mode Position
// Arrow head style
HeadSize float64
HeadStyle ArrowHeadStyle
ShowStart bool // Show arrow head at start
ShowEnd bool // Show arrow head at end
DoubleHead bool // Deprecated: use ShowStart and ShowEnd
// Curvature for curved arrows (0 = straight)
Curve float64
Style AnnotationStyle
}
Arrow represents an arrow annotation
func NewArrow ¶
func NewArrow(x1, y1, x2, y2 interface{}) *Arrow
NewArrow creates a new arrow annotation with data positioning
func NewArrowPixel ¶
NewArrowPixel creates a new arrow with pixel positioning
func (*Arrow) WithDoubleHead ¶
WithDoubleHead makes the arrow double-headed
func (*Arrow) WithEndHead ¶
WithEndHead controls the end arrow head
func (*Arrow) WithHeadSize ¶
WithHeadSize sets the arrow head size
func (*Arrow) WithHeadStyle ¶
func (a *Arrow) WithHeadStyle(style ArrowHeadStyle) *Arrow
WithHeadStyle sets the arrow head style
func (*Arrow) WithStartHead ¶
WithStartHead controls the start arrow head
func (*Arrow) WithStyle ¶
func (a *Arrow) WithStyle(style AnnotationStyle) *Arrow
WithStyle sets the style
type ArrowHeadStyle ¶
type ArrowHeadStyle string
ArrowHeadStyle defines the arrow head appearance
const ( ArrowHeadTriangle ArrowHeadStyle = "triangle" ArrowHeadOpen ArrowHeadStyle = "open" ArrowHeadDiamond ArrowHeadStyle = "diamond" ArrowHeadCircle ArrowHeadStyle = "circle" )
type CalloutLabel ¶
type CalloutLabel struct {
Text string
X, Y interface{} // Data point position
// Label position offset from point (in pixels)
LabelOffsetX, LabelOffsetY float64
// Whether to draw connecting line
ShowLine bool
Style AnnotationStyle
}
CalloutLabel is a text label with a line pointing to a data point
func NewCalloutLabel ¶
func NewCalloutLabel(text string, x, y interface{}) *CalloutLabel
NewCalloutLabel creates a new callout label
func (*CalloutLabel) Render ¶
func (cl *CalloutLabel) Render(xScale, yScale scales.Scale) string
Render renders the callout label
func (*CalloutLabel) WithLabelOffset ¶
func (cl *CalloutLabel) WithLabelOffset(x, y float64) *CalloutLabel
WithLabelOffset sets the label offset
func (*CalloutLabel) WithShowLine ¶
func (cl *CalloutLabel) WithShowLine(show bool) *CalloutLabel
WithShowLine sets whether to show the connecting line
func (*CalloutLabel) WithStyle ¶
func (cl *CalloutLabel) WithStyle(style AnnotationStyle) *CalloutLabel
WithStyle sets the style
type Connector ¶
type Connector struct {
X1, Y1, X2, Y2 interface{}
Mode Position
// Line style
LineStyle ConnectorStyle
Style AnnotationStyle
}
Connector draws a line connecting two points (no arrow heads)
func NewConnector ¶
func NewConnector(x1, y1, x2, y2 interface{}) *Connector
NewConnector creates a new connector
func (*Connector) WithLineStyle ¶
func (c *Connector) WithLineStyle(style ConnectorStyle) *Connector
WithLineStyle sets the connector line style
func (*Connector) WithStyle ¶
func (c *Connector) WithStyle(style AnnotationStyle) *Connector
WithStyle sets the style
type ConnectorStyle ¶
type ConnectorStyle string
ConnectorStyle defines connector line styles
const ( ConnectorStraight ConnectorStyle = "straight" ConnectorStep ConnectorStyle = "step" ConnectorStepBefore ConnectorStyle = "step-before" ConnectorStepAfter ConnectorStyle = "step-after" ConnectorElbow ConnectorStyle = "elbow" )
type Grid ¶
type Grid struct {
// Show horizontal and vertical grid lines
ShowHorizontal bool
ShowVertical bool
// Number of grid lines (0 = auto based on scale ticks)
HorizontalCount int
VerticalCount int
Style AnnotationStyle
}
Grid represents a reference grid
func (*Grid) WithCounts ¶
WithCounts sets the grid line counts
func (*Grid) WithStyle ¶
func (g *Grid) WithStyle(style AnnotationStyle) *Grid
WithStyle sets the style
type MultilineText ¶
type MultilineText struct {
Lines []string
X, Y interface{}
Mode Position
// Line spacing (multiplier of font size)
LineSpacing float64
OffsetX, OffsetY float64
Style AnnotationStyle
}
MultilineText represents a text annotation with multiple lines
func NewMultilineText ¶
func NewMultilineText(lines []string, x, y interface{}) *MultilineText
NewMultilineText creates a new multiline text annotation
func (*MultilineText) Render ¶
func (mt *MultilineText) Render(xScale, yScale scales.Scale) string
Render renders the multiline text
func (*MultilineText) WithLineSpacing ¶
func (mt *MultilineText) WithLineSpacing(spacing float64) *MultilineText
WithLineSpacing sets the line spacing
func (*MultilineText) WithStyle ¶
func (mt *MultilineText) WithStyle(style AnnotationStyle) *MultilineText
WithStyle sets the style
type Orientation ¶
type Orientation string
Orientation defines line orientation
const ( OrientationHorizontal Orientation = "horizontal" OrientationVertical Orientation = "vertical" )
type Position ¶
type Position string
Position represents how to position an annotation
const ( // PositionData positions relative to data coordinates (uses scales) PositionData Position = "data" // PositionPixel positions using absolute pixel coordinates PositionPixel Position = "pixel" // PositionRelative positions as percentage (0-1) of plot area PositionRelative Position = "relative" )
type ReferenceLine ¶
type ReferenceLine struct {
// Value in data coordinates
Value interface{}
// Orientation
Orientation Orientation
// Label (optional)
Label string
// Label position (0-1 along the line)
LabelPosition float64
// Label alignment
LabelAnchor Anchor
Style AnnotationStyle
}
ReferenceLine represents a horizontal or vertical reference line
func NewHLine ¶
func NewHLine(yValue interface{}) *ReferenceLine
NewHLine creates a new horizontal reference line
func NewVLine ¶
func NewVLine(xValue interface{}) *ReferenceLine
NewVLine creates a new vertical reference line
func (*ReferenceLine) Render ¶
func (rl *ReferenceLine) Render(xScale, yScale scales.Scale) string
Render renders the reference line
func (*ReferenceLine) WithDashed ¶
func (rl *ReferenceLine) WithDashed() *ReferenceLine
WithDashed makes the line dashed
func (*ReferenceLine) WithLabel ¶
func (rl *ReferenceLine) WithLabel(label string) *ReferenceLine
WithLabel sets the label
func (*ReferenceLine) WithLabelAnchor ¶
func (rl *ReferenceLine) WithLabelAnchor(anchor Anchor) *ReferenceLine
WithLabelAnchor sets the label anchor
func (*ReferenceLine) WithLabelPosition ¶
func (rl *ReferenceLine) WithLabelPosition(pos float64) *ReferenceLine
WithLabelPosition sets the label position (0-1)
func (*ReferenceLine) WithStyle ¶
func (rl *ReferenceLine) WithStyle(style AnnotationStyle) *ReferenceLine
WithStyle sets the style
type ReferenceRegion ¶
type ReferenceRegion struct {
// Data coordinates for region bounds
X1, Y1, X2, Y2 interface{}
// Use nil for unbounded dimensions (spans full range)
Mode Position
// Label (optional)
Label string
// Label position within region (0-1, 0-1)
LabelX, LabelY float64
Style AnnotationStyle
}
ReferenceRegion represents a shaded rectangular region
func NewHRegion ¶
func NewHRegion(y1, y2 interface{}) *ReferenceRegion
NewHRegion creates a horizontal band (full width, bounded Y)
func NewReferenceRegion ¶
func NewReferenceRegion(x1, y1, x2, y2 interface{}) *ReferenceRegion
NewReferenceRegion creates a new reference region
func NewVRegion ¶
func NewVRegion(x1, x2 interface{}) *ReferenceRegion
NewVRegion creates a vertical band (full height, bounded X)
func (*ReferenceRegion) Render ¶
func (rr *ReferenceRegion) Render(xScale, yScale scales.Scale) string
Render renders the reference region
func (*ReferenceRegion) WithLabel ¶
func (rr *ReferenceRegion) WithLabel(label string) *ReferenceRegion
WithLabel sets the label
func (*ReferenceRegion) WithLabelPosition ¶
func (rr *ReferenceRegion) WithLabelPosition(x, y float64) *ReferenceRegion
WithLabelPosition sets the label position (0-1, 0-1)
func (*ReferenceRegion) WithStyle ¶
func (rr *ReferenceRegion) WithStyle(style AnnotationStyle) *ReferenceRegion
WithStyle sets the style
type TextLabel ¶
type TextLabel struct {
// Text content
Text string
// Position in data coordinates (if PositionData)
X, Y interface{}
// Position in pixels (if PositionPixel)
PxX, PxY float64
// Position as relative (0-1) (if PositionRelative)
RelX, RelY float64
// Positioning mode
Mode Position
// Offset from position (in pixels)
OffsetX, OffsetY float64
// Rotation angle in degrees
Rotation float64
// Style
Style AnnotationStyle
}
TextLabel represents a text annotation
func NewTextLabel ¶
NewTextLabel creates a new text label with data positioning
func NewTextLabelPixel ¶
NewTextLabelPixel creates a new text label with pixel positioning
func NewTextLabelRelative ¶
NewTextLabelRelative creates a new text label with relative positioning
func (*TextLabel) WithAnchor ¶
WithAnchor sets the text anchor
func (*TextLabel) WithBaseline ¶
WithBaseline sets the text baseline
func (*TextLabel) WithOffset ¶
WithOffset sets the offset
func (*TextLabel) WithRotation ¶
WithRotation sets the rotation angle
func (*TextLabel) WithStyle ¶
func (tl *TextLabel) WithStyle(style AnnotationStyle) *TextLabel
WithStyle sets the style