viz

package
v0.0.0-...-f94f364 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

package viz defines common interfaces and data structures for generating visualizations.

Package viz provides plotting and diagramming utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
	Color  string
}

type Binding

type Binding struct {
	ElementID string  `json:"elementId"`
	Focus     float64 `json:"focus,omitempty"`
	Gap       float64 `json:"gap,omitempty"`
}

type BoundElement

type BoundElement struct{ Type, ID string }

type DataPoint

type DataPoint struct {
	X int64   // Typically Unix timestamp in milliseconds
	Y float64 // The value (e.g., latency, count)
}

DataPoint represents a single plot point for time-series charts.

type DataSeries

type DataSeries struct {
	Name   string
	Points []DataPoint
}

DataSeries represents a single named series of data points.

type DotGenerator

type DotGenerator struct{}

func (*DotGenerator) Generate

func (g *DotGenerator) Generate(diagram *protos.SystemDiagram) (string, error)

type DotTraceGenerator

type DotTraceGenerator struct{}

DotTraceGenerator generates a DOT graph from a trace.

func (*DotTraceGenerator) Generate

func (g *DotTraceGenerator) Generate(trace *runtime.TraceData) (string, error)

Generate creates a DOT graph string from trace data.

type ExcalidrawElement

type ExcalidrawElement struct {
	ID              string          `json:"id"`
	Type            string          `json:"type"`
	X               float64         `json:"x"`
	Y               float64         `json:"y"`
	Width           float64         `json:"width"`
	Height          float64         `json:"height"`
	Angle           float64         `json:"angle,omitempty"`
	StrokeColor     string          `json:"strokeColor"`
	BackgroundColor string          `json:"backgroundColor"`
	FillStyle       string          `json:"fillStyle"`
	StrokeWidth     int             `json:"strokeWidth"`
	StrokeStyle     string          `json:"strokeStyle"`
	Roughness       int             `json:"roughness"`
	Opacity         int             `json:"opacity"`
	Seed            int64           `json:"seed"`
	Version         int             `json:"version"`
	VersionNonce    int64           `json:"versionNonce"`
	IsDeleted       bool            `json:"isDeleted,omitempty"`
	BoundElements   []*BoundElement `json:"boundElements,omitempty"`
	StartBinding    *Binding        `json:"startBinding,omitempty"`
	EndBinding      *Binding        `json:"endBinding,omitempty"`
	Points          [][]float64     `json:"points,omitempty"`
	Text            string          `json:"text,omitempty"`
	FontSize        float64         `json:"fontSize,omitempty"`
	FontFamily      int             `json:"fontFamily,omitempty"`
	TextAlign       string          `json:"textAlign,omitempty"`
	VerticalAlign   string          `json:"verticalAlign,omitempty"`
	Baseline        int             `json:"baseline,omitempty"`
	ContainerId     *string         `json:"containerId,omitempty"`
	OriginalText    string          `json:"originalText,omitempty"`
	StrokeSharpness string          `json:"strokeSharpness,omitempty"`
	StartArrowhead  *string         `json:"startArrowhead,omitempty"`
	EndArrowhead    *string         `json:"endArrowhead,omitempty"`
}

type ExcalidrawFile

type ExcalidrawFile struct {
	Type, Version, Source string
	Elements              []*ExcalidrawElement
	AppState              map[string]any
	Files                 map[string]any
}

type ExcalidrawGenerator

type ExcalidrawGenerator struct{}

func (*ExcalidrawGenerator) Generate

func (g *ExcalidrawGenerator) Generate(diagram *protos.SystemDiagram) (string, error)

type ExcalidrawScene

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

type GridLine

type GridLine struct{ X1, Y1, X2, Y2 int }

type LegendItem

type LegendItem struct {
	Name, Color string
	X, Y        int
}

type MermaidSequenceGenerator

type MermaidSequenceGenerator struct{}

MermaidSequenceGenerator generates Mermaid sequence diagrams from a trace.

func (*MermaidSequenceGenerator) Generate

func (g *MermaidSequenceGenerator) Generate(trace *runtime.TraceData) (string, error)

Generate creates a Mermaid sequence diagram as a string.

type MermaidStaticGenerator

type MermaidStaticGenerator struct{}

func (*MermaidStaticGenerator) Generate

func (g *MermaidStaticGenerator) Generate(diagram *protos.SystemDiagram) (string, error)

type MultiSeriesPlotData

type MultiSeriesPlotData struct {
	Series   []DataSeries
	Metadata PlotMetadata
}

MultiSeriesPlotData represents a complete dataset for a multi-series plot.

type PlotConfig

type PlotConfig struct {
	Width        int
	Height       int
	MarginTop    int
	MarginRight  int
	MarginBottom int
	MarginLeft   int
	GridColor    string
	TextColor    string
	YAxisMode    YAxisMode // Y-axis scaling mode
	Colors       []string  // Palette for multi-series plots
	PlotType     PlotType
}

PlotConfig holds styling and dimension configuration.

func DefaultPlotConfig

func DefaultPlotConfig() PlotConfig

DefaultPlotConfig returns sensible defaults.

type PlotMetadata

type PlotMetadata struct {
	XLabel string `json:"xLabel,omitempty"`
	YLabel string `json:"yLabel,omitempty"`
	Title  string `json:"title,omitempty"`
}

PlotMetadata contains chart labels and title.

type PlotType

type PlotType string
const (
	LineChart PlotType = "line"
	BarChart  PlotType = "bar"
)

type Plotter

type Plotter interface {
	Generate(series []DataSeries, title, xLabel, yLabel string) (string, error)
}

Plotter defines the interface for creating plots and charts.

type SVGPlotter

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

SVGPlotter implements the Plotter interface to generate SVG charts.

func NewSVGPlotter

func NewSVGPlotter(config PlotConfig) *SVGPlotter

func (*SVGPlotter) Generate

func (p *SVGPlotter) Generate(series []DataSeries, title, xLabel, yLabel string) (string, error)

Generate creates an SVG string from a multi-series dataset.

type SequenceDiagramGenerator

type SequenceDiagramGenerator interface {
	Generate(trace *runtime.TraceData) (string, error)
}

SequenceDiagramGenerator defines the interface for creating dynamic sequence diagrams from a trace.

type SeriesPath

type SeriesPath struct{ Path, Color string }

type StaticDiagramGenerator

type StaticDiagramGenerator interface {
	Generate(diagram *protos.SystemDiagram) (string, error)
}

StaticDiagramGenerator defines the interface for creating static architecture diagrams.

type SvgGenerator

type SvgGenerator struct{}

func (*SvgGenerator) Generate

func (g *SvgGenerator) Generate(diagram *protos.SystemDiagram) (string, error)

type TemplateData

type TemplateData struct {
	Config      PlotConfig
	Metadata    PlotMetadata
	InnerWidth  int
	InnerHeight int
	XTicks      []XTick
	YTicks      []YTick
	GridLines   []GridLine
	SeriesPaths []SeriesPath
	Bars        []Bar
	LegendItems []LegendItem
}

TemplateData contains all data needed for SVG template rendering.

type XTick

type XTick struct {
	X, Y  int
	Label string
}

Helper structs for template rendering

type YAxisMode

type YAxisMode int

--- Value formatting and scaling helpers ---

const (
	YAxisAuto YAxisMode = iota
	YAxisZeroBased
	YAxisTight
	YAxisNice
)

type YTick

type YTick struct {
	X, Y  int
	Label string
}

Jump to

Keyboard shortcuts

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