svgkit

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package svgkit renders brand-agnostic, parametric SVG components (gauge, comparison-bar, chromatogram, icon) from JSON specs. Pure, deterministic, and dependency-free: every color/datum is caller-supplied (no brand tokens), and a given spec always yields byte-identical SVG. Used by the harness's generate_svg task for crisp, free, on-demand data-viz.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(kind string, spec json.RawMessage) (svg string, w, h int, err error)

Render renders the named component from its JSON spec and returns the SVG markup plus pixel dimensions. Unknown kind or unparseable spec returns an error.

Types

type BarItem

type BarItem struct {
	Label string  `json:"label"`
	Value float64 `json:"value"`
	Color string  `json:"color,omitempty"`
}

BarItem is one row in a comparison-bar chart.

type ChromatogramSpec

type ChromatogramSpec struct {
	Peaks  []Peak  `json:"peaks"`
	XMax   float64 `json:"x_max,omitempty"`
	Width  int     `json:"width,omitempty"`
	Height int     `json:"height,omitempty"`
	XLabel string  `json:"x_label,omitempty"`
	YLabel string  `json:"y_label,omitempty"`
	Theme  Theme   `json:"theme,omitempty"`
}

ChromatogramSpec describes an HPLC-style trace.

type ComparisonBarSpec

type ComparisonBarSpec struct {
	Items     []BarItem `json:"items"`
	Max       float64   `json:"max,omitempty"`
	Width     int       `json:"width,omitempty"`
	BarHeight int       `json:"bar_height,omitempty"`
	Unit      string    `json:"unit,omitempty"`
	Highlight int       `json:"highlight,omitempty"`
	Theme     Theme     `json:"theme,omitempty"`
}

ComparisonBarSpec describes a horizontal bar chart. Highlight is the index of the item to emphasize (use a negative value, e.g. -1, for none).

type GaugeSpec

type GaugeSpec struct {
	Value float64     `json:"value"`
	Min   float64     `json:"min,omitempty"`
	Max   float64     `json:"max,omitempty"`
	Label string      `json:"label,omitempty"`
	Unit  string      `json:"unit,omitempty"`
	Size  int         `json:"size,omitempty"`
	Zones []GaugeZone `json:"zones,omitempty"`
	Theme Theme       `json:"theme,omitempty"`
}

GaugeSpec describes a 270° radial dial, open at the bottom.

type GaugeZone

type GaugeZone struct {
	Upto  float64 `json:"upto"`
	Color string  `json:"color"`
}

GaugeZone colors the value arc up to the Upto threshold.

type IconSpec

type IconSpec struct {
	Name   string  `json:"name"`
	Size   int     `json:"size,omitempty"`
	Color  string  `json:"color,omitempty"`
	Stroke float64 `json:"stroke,omitempty"`
	Theme  Theme   `json:"theme,omitempty"`
}

IconSpec describes a stroke-based icon in a 24×24 viewBox scaled to Size.

type Peak

type Peak struct {
	RT     float64 `json:"rt"`
	Height float64 `json:"height"`
	Width  float64 `json:"width,omitempty"`
	Label  string  `json:"label,omitempty"`
}

Peak is one Gaussian peak in a chromatogram trace.

type Theme

type Theme struct {
	FG     string `json:"fg,omitempty"`
	BG     string `json:"bg,omitempty"`
	Accent string `json:"accent,omitempty"`
	Muted  string `json:"muted,omitempty"`
	Font   string `json:"font,omitempty"`
}

Theme is the brand-agnostic palette + type for a component. Empty fields fall back to a neutral slate default (NO brand tokens).

Jump to

Keyboard shortcuts

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