csirender

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 27 Imported by: 0

README

csirender

Version Go

csirender is a powerful, extensible, declarative 2D rendering engine written in Go. It enables you to design dynamic, data-driven dashboards and interfaces using simple YAML or JSON configurations, and render them to standard image formats (PNG, BMP) or raw data streams optimized for EPD (e-ink) displays.

Example Render (Image generated automatically from examples/assets/example.yaml)


🚀 Features

  • Declarative Configuration: Define your entire layout (Text, Charts, Value Cards, Lines, Images, Shapes) directly in YAML or JSON without writing rendering code.
  • Dynamic Styling (Thresholds): Change colors, backgrounds, image paths, and opacity dynamically based on real-time telemetry conditions (e.g., turn a background red if temperature > 30).
  • Rich Elements:
    • Text: Custom TrueType fonts, automatic text fitting, dynamic templating.
    • Images: PNG/JPEG/GIF support, scaling modes (fit, stretch, center), and alpha transparency.
    • Charts: Built-in line charts with customizable axes and threshold lines.
    • Shapes: Rectangles, circles, ellipses, and polygons with dynamic rotations (perfect for compasses/gauges).
  • Extensible Architecture: Implement the CustomRenderer interface to draw your own domain-specific components via a plugin system.
  • Optimized Caching Pipeline: The built-in Parser[T] seamlessly loads, caches, and watches configuration files for changes, ensuring your application only re-parses when necessary.

📦 Installation

go get github.com/ABespalov/csirender

🛠 Integration & Embedding Guide

csirender is designed to be deeply embedded into your business applications.

1. Define your Application Config

You can extend the base LayoutConfig with your own application-specific fields (like database credentials, server ports, etc.):

package main

import (
	"fmt"
	"github.com/ABespalov/csirender"
)

// AppConfig embeds csirender.LayoutConfig and adds custom logic
type AppConfig struct {
	csirender.LayoutConfig `yaml:",inline" json:",inline"`
	ListenAddr             string `yaml:"listen_addr" json:"listen_addr"`
}

// Create a caching parser for your specific config struct
var parser = csirender.NewParser[*AppConfig]()

func main() {
	// Parse loads and caches the layout
	cfg, err := parser.Parse("layout.yaml")
	if err != nil {
		panic(err)
	}
	fmt.Printf("Starting server on %s with screen width %d\n", cfg.ListenAddr, cfg.Screen.Width)
}
2. Prepare Telemetry and Render

Create an Engine, feed it your live data via RenderData, and generate the final image.

engine := csirender.New()

// Wrap flat maps using MapDataProvider for backward compatibility,
// or implement your own DataProvider for lazy evaluation!
data := &csirender.MapDataProvider{
	Data: csirender.RenderData{
		Values: map[string]interface{}{
			"temperature": 28.5,
			"weather_condition": "sun",
		},
		Charts: map[string][]float64{
			"temperature_history": {20, 22, 25, 27, 28.5},
		},
	},
}

// RenderWithProvider returns an image.Image
img, err := engine.RenderWithProvider(&cfg.LayoutConfig, data)
if err != nil {
	panic(err)
}

// You can now encode `img` to PNG/BMP and send it over HTTP or SPI.
// Or you can use csirender.EncodePartialImage(oldImg, img, "epd_pr", ...) for E-Ink partial refreshes!

For a complete, runnable client-server architecture, see the examples/server/ and examples/client/ examples.


⚙️ Configuration Reference

The library revolves around the LayoutConfig structure. Below is a comprehensive guide to its keys.

Global Settings
Key Description
screen.width / height Canvas dimensions in pixels.
screen.anti_aliasing Boolean. Enable for smooth lines, disable for sharp, pixel-perfect e-ink rendering.
screen.palette Map of logical color names to Hex codes (e.g., white: "#FFFFFF").
output.format Desired output serialization (png, bmp, epd_raw, epd_pr).
output.background Base canvas fill color.
fonts.<name> Define reusable font faces. Provide file (path to .ttf), size, and hinting (full, vertical, none).
Elements

All elements share these base properties:

  • type: Element kind (text, value, chart, line, image, shape).
  • position: x and y offset from the top-left corner.
  • size: w and h bounding box dimensions.
  • source: The telemetry key this element reacts to (e.g., temperature).
1. Text (type: text)

Displays static or dynamic strings.

  • template: A formatting string.
  • font: References a font from the global fonts block. Defines face, fg (foreground color), and bg.
  • align: h (left, center, right) and v (top, center, bottom).
  • fit_text: Boolean. Automatically scales down the font to fit the bounding box.
2. Value Card (type: value)

A complex component containing a value, label, and unit, wrapped in an optional border.

  • format: fmt.Sprintf style formatting (e.g., %.1f).
  • value, label, unit: Sub-configurations with their own font, align, and template.
  • border: Configuration for stroke (t, color) and background (bg).
  • Dynamic Thresholds:
    thresholds:
      - condition: "val > 30.0"
        bg: red
        fg: white
    
3. Chart (type: chart)

Plots historical data arrays.

  • points: Number of data points to display on the X-axis.
  • axis: Configuration for x and y axes (visibility, labels, fonts).
  • threshold_lines: Draw horizontal lines across the chart at specific values with custom color and style (e.g., dashed.4.4).
  • thresholds: Color regions of the chart based on the value.
4. Image (type: image)

Renders bitmap files.

  • path: Path to the image file.
  • mode: fit (maintains aspect ratio), stretch (fills bounds), or center (original size).
  • opacity: Float between 0.0 and 1.0.
  • Dynamic Swapping:
    thresholds:
        - condition: "val == 'rain'"
          path: "examples/assets/images/rain.png"
    
5. Shape (type: shape)

Draws geometric primitives.

  • kind: rect, circle, ellipse, polygon.
  • color: Fill color.
  • border: Stroke settings.
  • sides: Number of sides (for polygon).
  • rotation: Static rotation in degrees.
  • rotation_expr: Dynamic expression linked to telemetry (e.g., mapping wind direction to compass arrow rotation).

📜 Changelog

v0.2.0
  • Introduced EncodePartialImage to support epd_pr (partial refresh) incremental byte streaming for E-Ink displays.
  • Added 8x8 pixel bounding-box detection to compute minimal diffing rectangles between states.
  • Replaced RenderData with DataProvider interface for lazy evaluation of telemetry values and charts.
  • Added RenderWithProvider for new API consumers.
  • Maintained backward compatibility via MapDataProvider.
v0.1.0 (Initial Release)
  • Core declarative rendering engine.
  • Support for text, value, chart, line, image, and shape elements.
  • Caching Parser[T] for high-performance configuration reloading.
  • Dynamic threshold styling via condition evaluation.
  • Extensible CustomRenderer interface.

📄 License

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Documentation

Overview

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Package csirender provides an engine for declarative rendering of visual dashboards.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Copyright (c) 2026, Anton Bespalov. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeImage

func EncodeImage(img image.Image, format string, mapping map[string][]int, palette map[string]string) ([]byte, error)

EncodeImage wraps final formatting for the target output stream.

func EncodePartialImage added in v0.2.7

func EncodePartialImage(oldImg, newImg image.Image, format string, mapping map[string][]int, palette map[string]string) ([]byte, error)

EncodePartialImage encodes an image using the epd_pr (partial refresh) format. It compares oldImg and newImg to find bounding boxes of differences on a 4x4 grid. If oldImg is nil, it encodes the entire newImg as a single tile.

func PackEPDRaw

func PackEPDRaw(img image.Image, width, height int, mapping map[string][]int, palette map[string]string) []byte

PackEPDRaw takes an image.Image and packs its pixels into a byte array corresponding to the physical color indices of the target E-Ink display.

func RenderErrorImage

func RenderErrorImage(width, height int, errMsg string, format string, mapping map[string][]int, palette map[string]string, errorFontSize, marginX, marginY int) []byte

RenderErrorImage generates a safe fallback image containing error text.

func Version

func Version() string

Version returns the current version of the csirender library.

Types

type Align

type Align struct {
	H string  `yaml:"h" json:"h"` // Horizontal alignment: left, center, right
	V string  `yaml:"v" json:"v"` // Vertical alignment: top, center, bottom, under_center, under
	P string  `yaml:"p" json:"p"` // Placement relative to other elements: right, left, bottom, none
	S float64 `yaml:"s" json:"s"` // Spacing/gap size in pixels
}

Align defines vertical, horizontal, and relative alignments, along with spacers.

type BaseElement

type BaseElement struct {
	Type       string            `yaml:"type" json:"type"`                                 // Element type
	Position   Position          `yaml:"position" json:"position"`                         // Offset position on canvas
	Size       Size              `yaml:"size" json:"size"`                                 // Layout box dimensions
	Source     string            `yaml:"source,omitempty" json:"source,omitempty"`         // Data mapping path (e.g. "pm25.value")
	Parameters map[string]string `yaml:"parameters,omitempty" json:"parameters,omitempty"` // Arbitrary key-value parameters
}

BaseElement contains fields common to all visual elements.

func (*BaseElement) GetPosition

func (b *BaseElement) GetPosition() Position

func (*BaseElement) GetSize

func (b *BaseElement) GetSize() Size

func (*BaseElement) GetType

func (b *BaseElement) GetType() string

type BorderConfig

type BorderConfig struct {
	Bg         string      `yaml:"bg,omitempty" json:"bg,omitempty"`                 // Background fill color
	Padding    float64     `yaml:"padding,omitempty" json:"padding,omitempty"`       // Padding inside the border
	Affects    []string    `yaml:"affects,omitempty" json:"affects,omitempty"`       // Elements enclosed by the border
	Thresholds []Threshold `yaml:"thresholds,omitempty" json:"thresholds,omitempty"` // Dynamic styling overrides
	LineConfig `yaml:",inline" json:",inline"`
}

BorderConfig controls the border line and background of card components.

type ChartElement

type ChartElement struct {
	BaseElement    `yaml:",inline" json:",inline"`
	Style          string                 `yaml:"style,omitempty" json:"style,omitempty"`
	Duration       string                 `yaml:"duration,omitempty" json:"duration,omitempty"`
	RefreshDelay   string                 `yaml:"refresh_delay,omitempty" json:"refresh_delay,omitempty"`
	Points         int                    `yaml:"points,omitempty" json:"points,omitempty"`
	Axis           map[string]interface{} `yaml:"axis,omitempty" json:"axis,omitempty"`
	ThresholdLines []ThresholdLine        `yaml:"threshold_lines,omitempty" json:"threshold_lines,omitempty"`
	Thresholds     []Threshold            `yaml:"thresholds,omitempty" json:"thresholds,omitempty"`
	ChartType      string                 `yaml:"chart_type,omitempty" json:"chart_type,omitempty"` // Obsolete
}

ChartElement represents a graph or chart.

type ComponentConfig

type ComponentConfig struct {
	Font       FontStyle     `yaml:"font,omitempty" json:"font,omitempty"`             // Font settings
	Align      Align         `yaml:"align,omitempty" json:"align,omitempty"`           // Alignment settings
	Margin     Margin        `yaml:"margin,omitempty" json:"margin,omitempty"`         // Outer spacing
	Thresholds []Threshold   `yaml:"thresholds,omitempty" json:"thresholds,omitempty"` // Conditional styling overrides
	Border     *BorderConfig `yaml:"border,omitempty" json:"border,omitempty"`         // Optional border settings
	Template   string        `yaml:"template,omitempty" json:"template,omitempty"`     // Visual formatting template
	Parameter  string        `yaml:"parameter,omitempty" json:"parameter,omitempty"`   // Custom unit reference
}

ComponentConfig configures sub-components inside a complex widget like a value card.

type CustomRenderer

type CustomRenderer interface {
	RenderElement(dc *gg.Context, rc *RenderContext, el Element) error
}

CustomRenderer allows the parent application to draw domain-specific elements.

type DataProvider

type DataProvider interface {
	GetValue(key string) (interface{}, bool)
	GetChart(source string) ([]float64, bool)
	ResolveThreshold(condition string, chartSource string) (float64, bool)
	EnrichTelemetry(source string, value float64) map[string]interface{}
}

DataProvider defines an interface for lazy evaluation of telemetry values, charts, and thresholds.

type Element

type Element interface {
	GetType() string
	GetPosition() Position
	GetSize() Size
}

Element is a generic node representing a visual item inside a layout.

type ElementWrapper

type ElementWrapper struct {
	Element Element
}

ElementWrapper is a helper type for unmarshaling elements into their concrete types.

func (*ElementWrapper) UnmarshalJSON

func (w *ElementWrapper) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ElementWrapper. It dynamically detects the "type" field and unmarshals the JSON into the appropriate concrete struct.

func (*ElementWrapper) UnmarshalYAML

func (w *ElementWrapper) UnmarshalYAML(node *yaml.Node) error

type EmbeddedFont

type EmbeddedFont struct {
	Font   *opentype.Font
	PtSize float64
}

type Engine

type Engine struct {
	Resolver ValueResolver     // Deprecated: use DataProvider instead
	Enricher TelemetryEnricher // Deprecated: use DataProvider instead
	// contains filtered or unexported fields
}

Engine encapsulates the renderer and registered plugins.

func New

func New() *Engine

func (*Engine) GetImage

func (e *Engine) GetImage(path string) (image.Image, error)

GetImage loads an image from disk with caching.

func (*Engine) RegisterRenderer

func (e *Engine) RegisterRenderer(typ string, renderer CustomRenderer)

RegisterRenderer registers a plugin to handle a specific element type.

func (*Engine) Render

func (e *Engine) Render(cfg *LayoutConfig, data RenderData) (image.Image, error)

Render executes the full dashboard rendering pass and returns an image. Deprecated: use RenderWithProvider instead for lazy evaluation.

func (*Engine) RenderWithProvider

func (e *Engine) RenderWithProvider(cfg *LayoutConfig, provider DataProvider) (image.Image, error)

RenderWithProvider executes the full dashboard rendering pass using a lazy DataProvider.

type ErrorConfig

type ErrorConfig struct {
	Margin struct {
		X int `yaml:"x" json:"x"`
		Y int `yaml:"y" json:"y"`
	} `yaml:"margin" json:"margin"`
	Size int `yaml:"size" json:"size"`
}

ErrorConfig defines how errors are rendered.

type FontConfig

type FontConfig struct {
	File    string  `yaml:"file" json:"file"`       // Path to TrueType font file
	Size    float64 `yaml:"size" json:"size"`       // Default size of font
	Hinting string  `yaml:"hinting" json:"hinting"` // Hinting mode: none, vertical, full
}

FontConfig defines the TrueType font file and basic properties.

type FontStyle

type FontStyle struct {
	Face string `yaml:"face" json:"face"`
	Fg   string `yaml:"fg" json:"fg"`
	Bg   string `yaml:"bg" json:"bg"`
}

FontStyle groups font family reference and foreground/background colors.

type GenericElement

type GenericElement struct {
	BaseElement `yaml:",inline" json:",inline"`
	Raw         map[string]interface{} `yaml:",inline" json:",inline"`
}

GenericElement is a fallback for custom plugin elements.

type ImageElement

type ImageElement struct {
	BaseElement `yaml:",inline" json:",inline"`
	Path        string      `yaml:"path,omitempty" json:"path,omitempty"`
	Mode        string      `yaml:"mode,omitempty" json:"mode,omitempty"`
	Opacity     *float64    `yaml:"opacity,omitempty" json:"opacity,omitempty"`
	Align       Align       `yaml:"align,omitempty" json:"align,omitempty"`
	Thresholds  []Threshold `yaml:"thresholds,omitempty" json:"thresholds,omitempty"`
}

ImageElement represents a static or dynamic image.

type LayoutConfig

type LayoutConfig struct {
	Screen   ScreenConfig          `yaml:"screen" json:"screen"`
	Error    ErrorConfig           `yaml:"error" json:"error"`
	Defaults LayoutDefaults        `yaml:"defaults,omitempty" json:"defaults,omitempty"`
	Output   OutputConfig          `yaml:"output" json:"output"`
	Fonts    map[string]FontConfig `yaml:"fonts" json:"fonts"`
	Layout   []ElementWrapper      `yaml:"layout" json:"layout"` // Sequence of elements to draw
}

LayoutConfig represents the pure visual rendering configuration.

type LayoutDefaults

type LayoutDefaults struct {
	FitText *bool    `yaml:"fit_text,omitempty" json:"fit_text,omitempty"`
	Align   Align    `yaml:"align,omitempty" json:"align,omitempty"`
	Opacity *float64 `yaml:"opacity,omitempty" json:"opacity,omitempty"`
}

LayoutDefaults sets fallback values for visual properties.

type LineConfig

type LineConfig struct {
	Color string   `yaml:"color,omitempty" json:"color,omitempty"` // Stroke color
	T     *float64 `yaml:"t,omitempty" json:"t,omitempty"`         // Line thickness
	Style string   `yaml:"style,omitempty" json:"style,omitempty"` // Line style: solid, dashed, dotted, dashdot, or custom
}

LineConfig defines shared visual properties for lines.

type LineElement

type LineElement struct {
	BaseElement `yaml:",inline" json:",inline"`
	LineConfig  `yaml:",inline" json:",inline"`
	L           *float64 `yaml:"l,omitempty" json:"l,omitempty"`
	Angle       *float64 `yaml:"angle,omitempty" json:"angle,omitempty"`
}

LineElement renders a simple line or separator.

type LocalDataProvider

type LocalDataProvider struct {
	Parent    DataProvider
	Overrides map[string]interface{}
}

LocalDataProvider wraps an existing DataProvider and overrides specific keys.

func (*LocalDataProvider) EnrichTelemetry

func (l *LocalDataProvider) EnrichTelemetry(source string, value float64) map[string]interface{}

func (*LocalDataProvider) GetChart

func (l *LocalDataProvider) GetChart(source string) ([]float64, bool)

func (*LocalDataProvider) GetValue

func (l *LocalDataProvider) GetValue(key string) (interface{}, bool)

func (*LocalDataProvider) ResolveThreshold

func (l *LocalDataProvider) ResolveThreshold(condition string, chartSource string) (float64, bool)

type MapDataProvider

type MapDataProvider struct {
	Data     RenderData
	Resolver ValueResolver
	Enricher TelemetryEnricher
}

MapDataProvider is a compatibility wrapper that implements DataProvider using a static RenderData map and engine callbacks.

func (*MapDataProvider) EnrichTelemetry

func (p *MapDataProvider) EnrichTelemetry(source string, value float64) map[string]interface{}

func (*MapDataProvider) GetChart

func (p *MapDataProvider) GetChart(source string) ([]float64, bool)

func (*MapDataProvider) GetValue

func (p *MapDataProvider) GetValue(key string) (interface{}, bool)

func (*MapDataProvider) ResolveThreshold

func (p *MapDataProvider) ResolveThreshold(condition string, chartSource string) (float64, bool)

type Margin

type Margin struct {
	T float64 `yaml:"t" json:"t"` // Top margin
	B float64 `yaml:"b" json:"b"` // Bottom margin
	L float64 `yaml:"l" json:"l"` // Left margin
	R float64 `yaml:"r" json:"r"` // Right margin
}

Margin defines external spacing around components.

type OutputConfig

type OutputConfig struct {
	Format     string           `yaml:"format" json:"format"`         // Serialization format: epd_raw, png, bmp
	Background string           `yaml:"background" json:"background"` // Base fill color
	Mapping    map[string][]int `yaml:"mapping" json:"mapping"`       // Bit packing map for EPD outputs
}

OutputConfig configures serialization parameters.

type Parser

type Parser[T any] struct {
	// contains filtered or unexported fields
}

Parser handles loading and caching of generic configuration structures. It allows business applications to define their own config struct that embeds LayoutConfig, parse it efficiently, and cache the parsed result to avoid expensive re-parsing.

func NewParser

func NewParser[T any]() *Parser[T]

NewParser creates a new caching configuration parser.

func (*Parser[T]) Parse

func (p *Parser[T]) Parse(path string) (T, error)

Parse loads a configuration file. It uses the file extension to determine whether to use JSON or YAML parser. It caches the parsed object based on the file's modification time. Note: The returned configuration is a cached instance and should be treated as read-only.

type Position

type Position struct {
	X float64 `yaml:"x" json:"x"`
	Y float64 `yaml:"y" json:"y"`
}

Position defines the 2D coordinate of a visual element on the screen (in pixels).

type RenderContext

type RenderContext struct {
	// contains filtered or unexported fields
}

RenderContext holds state for drawing elements on the GG context.

type RenderData

type RenderData struct {
	Values map[string]interface{}
	Charts map[string][]float64
}

RenderData holds flattened telemetry and pre-sampled charts

type ScreenConfig

type ScreenConfig struct {
	Width        int               `yaml:"width" json:"width"`                 // Canvas width in pixels
	Height       int               `yaml:"height" json:"height"`               // Canvas height in pixels
	AntiAliasing bool              `yaml:"anti_aliasing" json:"anti_aliasing"` // Enable/disable anti-aliasing
	Palette      map[string]string `yaml:"palette" json:"palette"`             // Logical palette color mappings
}

ScreenConfig defines the canvas dimensions and palette.

type ShapeElement

type ShapeElement struct {
	BaseElement  `yaml:",inline" json:",inline"`
	Kind         string        `yaml:"kind,omitempty" json:"kind,omitempty"`                   // "rect", "circle", "ellipse", "polygon"
	Color        string        `yaml:"color,omitempty" json:"color,omitempty"`                 // Fill color
	Border       *BorderConfig `yaml:"border,omitempty" json:"border,omitempty"`               // Stroke/border settings
	CornerRadius float64       `yaml:"corner_radius,omitempty" json:"corner_radius,omitempty"` // For "rect"
	Sides        int           `yaml:"sides,omitempty" json:"sides,omitempty"`                 // For "polygon"
	Rotation     float64       `yaml:"rotation,omitempty" json:"rotation,omitempty"`           // Static rotation in degrees
	RotationExpr string        `yaml:"rotation_expr,omitempty" json:"rotation_expr,omitempty"` // Dynamic rotation expression/source
	Thresholds   []Threshold   `yaml:"thresholds,omitempty" json:"thresholds,omitempty"`
}

ShapeElement represents a geometric primitive (rectangle, circle, polygon).

type Size

type Size struct {
	W float64 `yaml:"w" json:"w"`
	H float64 `yaml:"h" json:"h"`
}

Size defines the dimensions of a visual container (in pixels).

type TelemetryEnricher

type TelemetryEnricher func(source string, value float64) map[string]interface{}

TelemetryEnricher is an optional callback that injects derived key-value pairs into the local telemetry map when evaluating per-bar or per-label thresholds. It receives the chart source name and the current bar/label value, and returns any additional keys that should be visible in the condition expression.

type TextElement

type TextElement struct {
	BaseElement `yaml:",inline" json:",inline"`
	Font        FontStyle `yaml:"font,omitempty" json:"font,omitempty"`
	Align       Align     `yaml:"align,omitempty" json:"align,omitempty"`
	Color       string    `yaml:"color,omitempty" json:"color,omitempty"`
	Template    string    `yaml:"template,omitempty" json:"template,omitempty"`
	FitText     *bool     `yaml:"fit_text,omitempty" json:"fit_text,omitempty"`
}

TextElement represents a text component.

type Threshold

type Threshold struct {
	Condition string   `yaml:"condition,omitempty" json:"condition,omitempty"` // Comparison expression (e.g. "aqi.us.zone.index >= 3")
	Label     string   `yaml:"label,omitempty" json:"label,omitempty"`         // Custom text label on match
	Bg        string   `yaml:"bg,omitempty" json:"bg,omitempty"`               // Custom background color on match
	Fg        string   `yaml:"fg,omitempty" json:"fg,omitempty"`               // Custom foreground/text color on match
	Color     string   `yaml:"color,omitempty" json:"color,omitempty"`         // Hex color code reference
	Path      string   `yaml:"path,omitempty" json:"path,omitempty"`           // Image path override
	Opacity   *float64 `yaml:"opacity,omitempty" json:"opacity,omitempty"`     // Opacity override
}

Threshold defines a condition-based styling override.

type ThresholdLine

type ThresholdLine struct {
	Condition  string  `yaml:"condition,omitempty" json:"condition,omitempty"` // Expression to trigger the line
	Value      float64 `yaml:"value,omitempty" json:"value,omitempty"`         // Static threshold value
	LineConfig `yaml:",inline" json:",inline"`
}

ThresholdLine configures a horizontal threshold line drawn on charts.

type ValueCardElement

type ValueCardElement struct {
	BaseElement `yaml:",inline" json:",inline"`
	Value       ComponentConfig `yaml:"value,omitempty" json:"value,omitempty"`
	Label       ComponentConfig `yaml:"label,omitempty" json:"label,omitempty"`
	Unit        ComponentConfig `yaml:"unit,omitempty" json:"unit,omitempty"`
	Border      *BorderConfig   `yaml:"border,omitempty" json:"border,omitempty"`
	Format      string          `yaml:"format,omitempty" json:"format,omitempty"`
	Padding     float64         `yaml:"padding,omitempty" json:"padding,omitempty"`
	Radius      float64         `yaml:"radius,omitempty" json:"radius,omitempty"`
}

ValueCardElement represents a complex value displaying component.

type ValueResolver

type ValueResolver func(condition string, chartSource string) (float64, bool)

ValueResolver defines a callback to resolve condition strings to concrete chart values.

Directories

Path Synopsis
examples
client command
server command

Jump to

Keyboard shortcuts

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