Documentation
¶
Index ¶
- func ChartCell(row, col, rowSpan, colSpan int) *layout.Node
- func ChartGrid(rows, cols int) *layout.Node
- func ChartGridCustom(rowTracks, colTracks []layout.GridTrack) *layout.Node
- func ChartGridWithGap(rows, cols int, gap float64) *layout.Node
- func ChartHStack() *layout.Node
- func ChartVStack() *layout.Node
- func ComputeMarginForAxes(hasLeft, hasRight, hasTop, hasBottom, hasTitle bool) (top, right, bottom, left float64)
- func ComputeSharedDomain(facets []FacetData, field string) (min, max float64)
- func DefaultChartMargin() (top, right, bottom, left float64)
- func GetScaleDomain(facets []FacetData, facetIndex int, field string, sharing ScaleSharing) (min, max float64)
- func QuadLayout(width, height float64) *layout.Node
- func RenderChartTree(root *layout.Node, width, height float64, renderFunc func(*layout.Node) string) string
- func SideBySideLayout(width, height float64) *layout.Node
- func TopBottomLayout(width, height float64) *layout.Node
- func TraverseAndRender(node *layout.Node) string
- func WithCustomMargin(node *layout.Node, top, right, bottom, left float64) *layout.Node
- func WithCustomPadding(node *layout.Node, top, right, bottom, left float64) *layout.Node
- func WithFlexGrow(node *layout.Node, grow float64) *layout.Node
- func WithMargin(node *layout.Node, margin float64) *layout.Node
- func WithPadding(node *layout.Node, padding float64) *layout.Node
- func WithSize(node *layout.Node, width, height float64) *layout.Node
- type ChartNode
- type ChartRenderer
- type Dashboard
- type FacetData
- type FacetLayout
- type FacetPlot
- func (fp *FacetPlot) Render() string
- func (fp *FacetPlot) WithCellRenderer(renderer func(data []transforms.DataPoint, bounds layout.Rect) string) *FacetPlot
- func (fp *FacetPlot) WithData(data []transforms.DataPoint) *FacetPlot
- func (fp *FacetPlot) WithTitleRenderer(renderer func(value string, bounds layout.Rect) string) *FacetPlot
- type FacetSpec
- func (f *FacetSpec) BuildLayout(numFacets int, width, height float64) *layout.Node
- func (f *FacetSpec) CalculateDimensions(numFacets int) (rows, cols int)
- func (f *FacetSpec) Split(data []transforms.DataPoint) []FacetData
- func (f *FacetSpec) WithCols(cols int) *FacetSpec
- func (f *FacetSpec) WithFacetMargin(margin float64) *FacetSpec
- func (f *FacetSpec) WithGap(gap float64) *FacetSpec
- func (f *FacetSpec) WithOrder(order []string) *FacetSpec
- func (f *FacetSpec) WithRows(rows int) *FacetSpec
- func (f *FacetSpec) WithScaleSharing(sharing ScaleSharing) *FacetSpec
- func (f *FacetSpec) WithTitles(show bool) *FacetSpec
- type MarginConvention
- func (mc *MarginConvention) AsNode() *layout.Node
- func (mc *MarginConvention) BottomMarginArea() layout.Rect
- func (mc *MarginConvention) LeftMarginArea() layout.Rect
- func (mc *MarginConvention) PlotArea() layout.Rect
- func (mc *MarginConvention) PlotHeight() float64
- func (mc *MarginConvention) PlotWidth() float64
- func (mc *MarginConvention) RightMarginArea() layout.Rect
- func (mc *MarginConvention) SetMargin(top, right, bottom, left float64) *MarginConvention
- func (mc *MarginConvention) SetUniformMargin(margin float64) *MarginConvention
- func (mc *MarginConvention) TopMarginArea() layout.Rect
- func (mc *MarginConvention) TotalBounds() layout.Rect
- type ScaleSharing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChartGrid ¶
ChartGrid creates a CSS Grid layout for charts Uses fr units to create equally-sized cells
func ChartGridCustom ¶
ChartGridCustom creates a grid with custom track sizes
func ChartGridWithGap ¶
ChartGridWithGap creates a grid with gap between cells
func ChartHStack ¶
ChartHStack creates a horizontal flexbox stack of charts
func ChartVStack ¶
ChartVStack creates a vertical flexbox stack of charts
func ComputeMarginForAxes ¶
func ComputeMarginForAxes(hasLeft, hasRight, hasTop, hasBottom, hasTitle bool) (top, right, bottom, left float64)
ComputeMarginForAxes automatically computes margins based on axis requirements
func ComputeSharedDomain ¶
ComputeSharedDomain calculates shared domain across all facets
func DefaultChartMargin ¶
func DefaultChartMargin() (top, right, bottom, left float64)
DefaultChartMargin returns typical margins for a chart with axes
func GetScaleDomain ¶
func GetScaleDomain(facets []FacetData, facetIndex int, field string, sharing ScaleSharing) (min, max float64)
GetScaleDomain returns the domain for a scale based on sharing strategy
func QuadLayout ¶
QuadLayout creates a 2x2 grid layout
func RenderChartTree ¶
func RenderChartTree(root *layout.Node, width, height float64, renderFunc func(*layout.Node) string) string
Helper to render chart nodes to SVG
func SideBySideLayout ¶
SideBySideLayout creates a 1x2 grid layout
func TopBottomLayout ¶
TopBottomLayout creates a 2x1 grid layout
func TraverseAndRender ¶
TraverseAndRender walks the tree and renders each chart node
func WithCustomMargin ¶
WithCustomMargin adds custom margin to each side
func WithCustomPadding ¶
WithCustomPadding adds custom padding to each side
func WithFlexGrow ¶
WithFlexGrow sets the flex grow factor
func WithMargin ¶
WithMargin adds margin to a chart node
func WithPadding ¶
WithPadding adds padding to a chart node
Types ¶
type ChartNode ¶
type ChartNode struct {
*layout.Node
// Chart-specific metadata
ChartType string // Type of chart (bar, line, scatter, etc.)
Data interface{} // Chart data
Renderer ChartRenderer // Function to render this chart
}
ChartNode wraps a layout.Node with chart-specific functionality This provides the bridge between dataviz concepts and the layout engine
func (*ChartNode) WithRenderer ¶
func (cn *ChartNode) WithRenderer(renderer ChartRenderer) *ChartNode
WithRenderer sets the chart renderer
type ChartRenderer ¶
ChartRenderer renders a chart within its layout bounds
type Dashboard ¶
Dashboard creates a flexible dashboard layout Allows charts to specify their grid position and span
func NewDashboard ¶
NewDashboard creates a new dashboard
type FacetData ¶
type FacetData struct {
Value string // Facet category value
Data []transforms.DataPoint // Data points for this facet
Index int // Position in facet order
Node *layout.Node // Layout node for this facet
}
FacetData holds data split by facet values
type FacetLayout ¶
FacetLayout creates a grid layout for faceted plots
func NewFacetLayout ¶
func NewFacetLayout(rows, cols int, width, height float64) *FacetLayout
NewFacetLayout creates a new facet layout
func (*FacetLayout) Build ¶
func (fl *FacetLayout) Build() *layout.Node
Build creates the layout node
type FacetPlot ¶
type FacetPlot struct {
Spec *FacetSpec
Width float64
Height float64
Data []transforms.DataPoint
// Renderer for each facet cell
CellRenderer func(data []transforms.DataPoint, bounds layout.Rect) string
// Optional title renderer
TitleRenderer func(value string, bounds layout.Rect) string
}
FacetPlot creates a faceted visualization
func NewFacetPlot ¶
NewFacetPlot creates a new faceted plot
func (*FacetPlot) WithCellRenderer ¶
func (fp *FacetPlot) WithCellRenderer(renderer func(data []transforms.DataPoint, bounds layout.Rect) string) *FacetPlot
WithCellRenderer sets the cell renderer
type FacetSpec ¶
type FacetSpec struct {
// Field to facet by (DataPoint.Group or other field)
Field string
// Number of columns
NCols int
// Number of rows (0 = auto)
NRows int
// Scale sharing strategy
ScaleSharing ScaleSharing
// Whether to show titles for each facet
ShowTitles bool
// Custom ordering for facet values
Order []string
// Gap between facets
Gap float64
// Margin around each facet plot area
FacetMargin float64
}
Facet represents a specification for creating small multiples
func NewFacetSpec ¶
NewFacetSpec creates a new facet specification
func (*FacetSpec) BuildLayout ¶
BuildLayout creates a CSS Grid layout for facets
func (*FacetSpec) CalculateDimensions ¶
CalculateDimensions calculates grid dimensions based on number of facets
func (*FacetSpec) Split ¶
func (f *FacetSpec) Split(data []transforms.DataPoint) []FacetData
Split splits data into facets based on the field
func (*FacetSpec) WithFacetMargin ¶
WithFacetMargin sets the margin around each facet
func (*FacetSpec) WithScaleSharing ¶
func (f *FacetSpec) WithScaleSharing(sharing ScaleSharing) *FacetSpec
WithScaleSharing sets the scale sharing strategy
func (*FacetSpec) WithTitles ¶
WithTitles sets whether to show titles
type MarginConvention ¶
type MarginConvention struct {
// contains filtered or unexported fields
}
MarginConvention implements the D3 margin convention for charts This pattern reserves space for axes, titles, and labels around a plot area
Example:
mc := NewMarginConvention(800, 600) mc.SetMargin(60, 20, 50, 60) // top, right, bottom, left plotArea := mc.PlotArea() // Get inner drawing area
func NewMarginConvention ¶
func NewMarginConvention(width, height float64) *MarginConvention
NewMarginConvention creates a new margin convention
func (*MarginConvention) AsNode ¶
func (mc *MarginConvention) AsNode() *layout.Node
AsNode creates a layout.Node with the margin convention applied
func (*MarginConvention) BottomMarginArea ¶
func (mc *MarginConvention) BottomMarginArea() layout.Rect
BottomMarginArea returns the bounds of the bottom margin (for X axis)
func (*MarginConvention) LeftMarginArea ¶
func (mc *MarginConvention) LeftMarginArea() layout.Rect
LeftMarginArea returns the bounds of the left margin (for Y axis)
func (*MarginConvention) PlotArea ¶
func (mc *MarginConvention) PlotArea() layout.Rect
PlotArea returns a Rect representing the plot area
func (*MarginConvention) PlotHeight ¶
func (mc *MarginConvention) PlotHeight() float64
PlotHeight returns the height of the plot area
func (*MarginConvention) PlotWidth ¶
func (mc *MarginConvention) PlotWidth() float64
PlotWidth returns the width of the plot area
func (*MarginConvention) RightMarginArea ¶
func (mc *MarginConvention) RightMarginArea() layout.Rect
RightMarginArea returns the bounds of the right margin
func (*MarginConvention) SetMargin ¶
func (mc *MarginConvention) SetMargin(top, right, bottom, left float64) *MarginConvention
SetMargin sets all margins at once
func (*MarginConvention) SetUniformMargin ¶
func (mc *MarginConvention) SetUniformMargin(margin float64) *MarginConvention
SetUniformMargin sets the same margin on all sides
func (*MarginConvention) TopMarginArea ¶
func (mc *MarginConvention) TopMarginArea() layout.Rect
TopMarginArea returns the bounds of the top margin (for title)
func (*MarginConvention) TotalBounds ¶
func (mc *MarginConvention) TotalBounds() layout.Rect
TotalBounds returns the full canvas bounds
type ScaleSharing ¶
type ScaleSharing string
ScaleSharing defines how scales are shared across facets
const ( )