theme

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContrastRatio

func ContrastRatio(color1, color2 string) float64

ContrastRatio calculates the WCAG contrast ratio between two colors

func CoolWarmColors

func CoolWarmColors(t float64) string

CoolWarmColors returns colors from a cool-warm diverging palette (-1 to 1)

func DarkCategorical

func DarkCategorical() []string

DarkCategorical returns a categorical color palette for dark mode

func DarkDiverging

func DarkDiverging(accent string) []string

DarkDiverging returns a diverging color palette for dark mode

func DarkSequential

func DarkSequential(accent string) []string

DarkSequential returns a sequential color palette for dark mode

func EnsureContrast

func EnsureContrast(fg, bg string, minRatio float64) string

EnsureContrast adjusts a foreground color to ensure sufficient contrast with background

func HeatmapColors

func HeatmapColors(value float64, darkMode bool) string

HeatmapColors returns colors for a heatmap based on value (0-1)

func LightCategorical

func LightCategorical() []string

LightCategorical returns a categorical color palette for light mode

func LightDiverging

func LightDiverging(accent string) []string

LightDiverging returns a diverging color palette for light mode

func LightSequential

func LightSequential(accent string) []string

LightSequential returns a sequential color palette for light mode

func PlasmaColors

func PlasmaColors(t float64) string

PlasmaColors returns colors from the Plasma palette (0-1) Plasma is another perceptually uniform color map

func QualitativeColors

func QualitativeColors(index int, darkMode bool) string

QualitativeColors returns high-contrast colors for categorical data

func ViridisColors

func ViridisColors(t float64) string

ViridisColors returns colors from the Viridis palette (0-1) Viridis is a perceptually uniform color map

Types

type ChartStyle

type ChartStyle struct {
	// Stroke widths
	GridStrokeWidth float64
	AxisStrokeWidth float64
	DataStrokeWidth float64

	// Opacities
	GridOpacity float64
	FillOpacity float64

	// Marker sizes
	PointSize  float64
	MarkerSize float64

	// Spacing
	Padding      float64
	MarginTop    float64
	MarginRight  float64
	MarginBottom float64
	MarginLeft   float64

	// Border radius for bars, boxes, etc.
	BarRadius  float64
	CardRadius float64
}

ChartStyle defines chart-specific styling

type ColorScheme

type ColorScheme struct {
	// Sequential palette (for ordered data)
	Sequential []string

	// Diverging palette (for data with a midpoint)
	Diverging []string

	// Categorical palette (for distinct categories)
	Categorical []string

	// Special colors
	GridColor       string
	AxisColor       string
	TextColor       string
	BackgroundColor string
	BorderColor     string
}

ColorScheme defines color palettes for different chart elements

type Theme

type Theme struct {
	// Design tokens from design-system package
	Tokens *design.DesignTokens

	// Color palettes for data visualization
	ColorScheme ColorScheme

	// Typography settings
	Typography Typography

	// Chart-specific styling
	Chart ChartStyle
}

Theme represents a complete visual theme for dataviz charts

func Default

func Default() *Theme

Default returns the default theme

func Forest

func Forest(darkMode bool) *Theme

Forest returns a forest-inspired theme

func FromTokens

func FromTokens(tokens *design.DesignTokens) *Theme

FromTokens creates a theme from custom design tokens

func HighContrast

func HighContrast(darkMode bool) *Theme

HighContrast returns a high contrast theme for accessibility

func Midnight

func Midnight() *Theme

Midnight returns the midnight theme (dark, deep blues)

func Minimal

func Minimal() *Theme

Minimal returns a minimal theme with subtle styling

func Monochrome

func Monochrome(darkMode bool) *Theme

Monochrome returns a monochrome theme (grayscale)

func New

func New(tokens *design.DesignTokens) *Theme

New creates a new theme from design tokens

func Nord

func Nord() *Theme

Nord returns the Nord theme (muted, cool colors)

func Ocean

func Ocean(darkMode bool) *Theme

Ocean returns an ocean-inspired theme

func Paper

func Paper() *Theme

Paper returns the Paper theme (light, clean)

func Scientific

func Scientific() *Theme

Scientific returns a theme suitable for scientific publications

func Sunset

func Sunset(darkMode bool) *Theme

Sunset returns a sunset-inspired theme

func Wrapped

func Wrapped() *Theme

Wrapped returns the Wrapped theme (vibrant, special styling)

func (*Theme) AxisStyle

func (t *Theme) AxisStyle() svg.Style

AxisStyle returns SVG style for axis lines

func (*Theme) BodyStyle

func (t *Theme) BodyStyle() svg.Style

BodyStyle returns SVG style for body text

func (*Theme) GetColor

func (t *Theme) GetColor(index int) string

GetColor returns a color from the categorical palette at the given index

func (*Theme) GetDivergingColor

func (t *Theme) GetDivergingColor(t_value float64) string

GetDivergingColor returns a color from the diverging palette (-1.0 to 1.0)

func (*Theme) GetSequentialColor

func (t *Theme) GetSequentialColor(t_value float64) string

GetSequentialColor returns a color from the sequential palette (0.0 to 1.0)

func (*Theme) GridStyle

func (t *Theme) GridStyle() svg.Style

GridStyle returns SVG style for grid lines

func (*Theme) LabelStyle

func (t *Theme) LabelStyle() svg.Style

LabelStyle returns SVG style for axis labels

func (*Theme) TitleStyle

func (t *Theme) TitleStyle() svg.Style

TitleStyle returns SVG style for chart titles

type Typography

type Typography struct {
	// Font families
	TitleFont string
	BodyFont  string
	MonoFont  string

	// Font sizes
	TitleSize    units.Length
	SubtitleSize units.Length
	BodySize     units.Length
	CaptionSize  units.Length
	LabelSize    units.Length

	// Font weights
	TitleWeight svg.FontWeight
	BodyWeight  svg.FontWeight
	LabelWeight svg.FontWeight

	// Line heights (multipliers)
	TitleLineHeight float64
	BodyLineHeight  float64
}

Typography defines font settings for charts

Jump to

Keyboard shortcuts

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