dashboard

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dashboard provides HTML dashboard generation for PRISM maturity models.

Package dashboard provides HTML dashboard generation for PRISM maturity models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(values []float64, method AggregationMethod) float64

Aggregate computes an aggregate value from a slice of values using the specified method.

func GetMaturityBulletCSS

func GetMaturityBulletCSS() string

GetMaturityBulletCSS returns CSS for maturity-colored bullet charts. D3 sorts ranges descending: s0=highest(M5), s1=middle(M4), s2=lowest(M1-3). Zone colors: M5 = green (right), M4 = yellow (middle), M1-M3 = red (left).

func GetMaturityBulletCSSStyled

func GetMaturityBulletCSSStyled() string

GetMaturityBulletCSSStyled returns CSS with the style tags included.

func MaturityLevel

func MaturityLevel(value float64) string

MaturityLevel returns the maturity level label (M1-M5) for a numeric value.

func MaturityStatus

func MaturityStatus(level float64) string

MaturityStatus returns the status (green/yellow/red) for a maturity level.

func MaturityStatusEmoji

func MaturityStatusEmoji(level float64) string

MaturityStatusEmoji returns an emoji indicator for a maturity level.

Types

type AggregationMethod

type AggregationMethod string

AggregationMethod defines how to aggregate maturity levels.

const (
	// AggregationMin uses the minimum value (most conservative).
	AggregationMin AggregationMethod = "min"
	// AggregationAvg uses the average value.
	AggregationAvg AggregationMethod = "avg"
)

type Axis

type Axis struct {
	ID       string   `json:"id"`
	Type     string   `json:"type"`
	Position string   `json:"position"`
	Name     string   `json:"name,omitempty"`
	Min      *float64 `json:"min,omitempty"`
	Max      *float64 `json:"max,omitempty"`
}

Axis defines a chart axis.

type CapabilityMaturity

type CapabilityMaturity struct {
	CapabilityID   string            `json:"capabilityId"`
	CapabilityName string            `json:"capabilityName"`
	LayerID        string            `json:"layerId"`
	SLIIDs         []string          `json:"sliIds"`
	SLILevels      []float64         `json:"sliLevels"`
	AggregateLevel float64           `json:"aggregateLevel"`
	Method         AggregationMethod `json:"method"`
}

CapabilityMaturity holds aggregated maturity data for a single capability.

type ChartConfig

type ChartConfig struct {
	Marks   []Mark   `json:"marks"`
	Axes    []Axis   `json:"axes,omitempty"`
	Grid    *Grid    `json:"grid,omitempty"`
	Legend  *Legend  `json:"legend,omitempty"`
	Tooltip *Tooltip `json:"tooltip,omitempty"`
}

ChartConfig configures a chart widget (ChartIR subset).

type Dashboard

type Dashboard struct {
	Schema      string       `json:"$schema,omitempty"`
	ID          string       `json:"id"`
	Title       string       `json:"title"`
	Description string       `json:"description,omitempty"`
	Layout      Layout       `json:"layout"`
	DataSources []DataSource `json:"dataSources"`
	Widgets     []Widget     `json:"widgets"`
	Theme       *Theme       `json:"theme,omitempty"`
}

Dashboard represents a Dashforge-compatible dashboard.

func (*Dashboard) ToHTML

func (d *Dashboard) ToHTML(opts HTMLOptions) (string, error)

ToHTML returns the dashboard as an HTML string.

func (*Dashboard) ToJSON

func (d *Dashboard) ToJSON() ([]byte, error)

ToJSON returns the dashboard as JSON bytes.

func (*Dashboard) WriteHTML

func (d *Dashboard) WriteHTML(w io.Writer, opts HTMLOptions) error

WriteHTML writes the dashboard as a standalone HTML file.

type DataSource

type DataSource struct {
	ID     string          `json:"id"`
	Type   string          `json:"type"`
	Data   json.RawMessage `json:"data,omitempty"`
	URL    string          `json:"url,omitempty"`
	Format string          `json:"format,omitempty"`
}

DataSource defines a data source for widgets.

type Encode

type Encode struct {
	X     string `json:"x,omitempty"`
	Y     string `json:"y,omitempty"`
	Value string `json:"value,omitempty"`
	Name  string `json:"name,omitempty"`
}

Encode maps data to visual channels.

type FormatOptions

type FormatOptions struct {
	Decimals int    `json:"decimals,omitempty"`
	Prefix   string `json:"prefix,omitempty"`
	Suffix   string `json:"suffix,omitempty"`
}

FormatOptions defines number formatting.

type Generator

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

Generator creates dashboards from maturity specs.

func NewGenerator

func NewGenerator(spec *maturity.Spec) *Generator

NewGenerator creates a dashboard generator for a maturity spec.

func (*Generator) Generate

func (g *Generator) Generate() (*Dashboard, error)

Generate creates a complete dashboard.

func (*Generator) GenerateMaturityBullets

func (g *Generator) GenerateMaturityBullets() *MaturityBulletData

GenerateMaturityBullets creates bullet chart data for all domains.

func (*Generator) WithAggregationMethod

func (g *Generator) WithAggregationMethod(method AggregationMethod) *Generator

WithAggregationMethod sets the aggregation method for capability/layer maturity. Defaults to AggregationMin if not set.

func (*Generator) WithCapabilityStack

func (g *Generator) WithCapabilityStack(cs *capstack.CapabilityStack) *Generator

WithCapabilityStack adds a capability stack for layer-based views. When set, the dashboard will include layer-grouped maturity visualizations.

func (*Generator) WithStateDocument

func (g *Generator) WithStateDocument(doc *prism.PRISMDocument) *Generator

WithStateDocument adds a PRISM Maturity State document for state tracking. When set, state is read from this document instead of the legacy assessments.

type Grid

type Grid struct {
	Left         string `json:"left,omitempty"`
	Right        string `json:"right,omitempty"`
	Top          string `json:"top,omitempty"`
	Bottom       string `json:"bottom,omitempty"`
	ContainLabel bool   `json:"containLabel,omitempty"`
}

Grid defines chart container positioning.

type HTMLOptions

type HTMLOptions struct {
	EmbedData bool   // Embed data in HTML instead of external JSON
	Title     string // Page title override
	Theme     string // "light" or "dark"
}

HTMLOptions configures HTML output.

func DefaultHTMLOptions

func DefaultHTMLOptions() HTMLOptions

DefaultHTMLOptions returns default HTML options.

type LayerMaturity

type LayerMaturity struct {
	LayerID        string               `json:"layerId"`
	LayerName      string               `json:"layerName"`
	Order          int                  `json:"order"`
	Capabilities   []CapabilityMaturity `json:"capabilities"`
	AggregateLevel float64              `json:"aggregateLevel"`
	Method         AggregationMethod    `json:"method"`
}

LayerMaturity holds aggregated maturity data for a capability layer.

type Layout

type Layout struct {
	Type      string `json:"type"`
	Columns   int    `json:"columns"`
	RowHeight int    `json:"rowHeight"`
	Gap       int    `json:"gap"`
	Padding   int    `json:"padding"`
}

Layout defines the dashboard grid layout.

type Legend

type Legend struct {
	Show     bool   `json:"show"`
	Position string `json:"position,omitempty"`
}

Legend configures chart legend.

type LevelThreshold

type LevelThreshold struct {
	Level    int     `json:"level"`              // Maturity level (1-5)
	Operator string  `json:"operator,omitempty"` // >=, <=, ==, etc.
	Value    float64 `json:"value"`              // Threshold value
	ValueStr string  `json:"valueStr,omitempty"` // Formatted value with unit
}

LevelThreshold defines the threshold for a specific maturity level.

type Mark

type Mark struct {
	ID       string `json:"id"`
	Geometry string `json:"geometry"`
	Encode   Encode `json:"encode"`
	Style    *Style `json:"style,omitempty"`
	Stack    string `json:"stack,omitempty"`
	Name     string `json:"name,omitempty"`
}

Mark represents a chart series.

type MaturityAggregator

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

MaturityAggregator calculates aggregate maturity across capabilities and layers.

func NewMaturityAggregator

func NewMaturityAggregator(
	spec *maturity.Spec,
	cs *capstack.CapabilityStack,
	stateDoc *prism.PRISMDocument,
	method AggregationMethod,
) *MaturityAggregator

NewMaturityAggregator creates a new maturity aggregator.

func (*MaturityAggregator) BuildSLIToCapabilityIndex

func (a *MaturityAggregator) BuildSLIToCapabilityIndex() SLIToCapabilityIndex

BuildSLIToCapabilityIndex creates a reverse index from SLI IDs to capability IDs.

func (*MaturityAggregator) CalculateCapabilityMaturity

func (a *MaturityAggregator) CalculateCapabilityMaturity(cap capstack.Capability) CapabilityMaturity

CalculateCapabilityMaturity computes the aggregate maturity for a capability.

func (*MaturityAggregator) CalculateLayerMaturity

func (a *MaturityAggregator) CalculateLayerMaturity(layer capstack.Layer) LayerMaturity

CalculateLayerMaturity computes the aggregate maturity for a layer.

func (*MaturityAggregator) GetCapabilityMaturities

func (a *MaturityAggregator) GetCapabilityMaturities() []CapabilityMaturity

GetCapabilityMaturities returns maturity data for all capabilities.

func (*MaturityAggregator) GetLayerMaturities

func (a *MaturityAggregator) GetLayerMaturities() []LayerMaturity

GetLayerMaturities returns maturity data for all layers, sorted by Order.

type MaturityBullet

type MaturityBullet struct {
	Title       string           `json:"title,omitempty"`
	Subtitle    string           `json:"subtitle,omitempty"`
	Ranges      []float64        `json:"ranges,omitempty"`      // Zone boundaries [M3, M4, M5]
	Measures    []float64        `json:"measures,omitempty"`    // Current maturity level(s)
	Markers     []float64        `json:"markers,omitempty"`     // Target level(s)
	ActualValue string           `json:"actualValue,omitempty"` // Actual SLI value with unit (e.g., "65%", "120ms")
	Thresholds  []LevelThreshold `json:"thresholds,omitempty"`  // Thresholds for each maturity level
}

MaturityBullet represents a D3 bullet chart for maturity visualization. Ranges are configured for M1-M3 (red), M4 (yellow), M5 (green) zones.

func NewMaturityBullet

func NewMaturityBullet(title, subtitle string, currentLevel, targetLevel float64) MaturityBullet

NewMaturityBullet creates a bullet chart for a maturity metric. currentLevel is the actual achieved level (0-5). targetLevel is the target level (0-5), use 0 for no target marker.

func NewMaturityBulletWithDetails

func NewMaturityBulletWithDetails(title string, currentLevel, targetLevel, actualValue float64, unit, qualitativeState string, thresholds []LevelThreshold) MaturityBullet

NewMaturityBulletWithDetails creates a bullet chart with actual SLI value and thresholds.

func NewMaturityBulletWithProjection

func NewMaturityBulletWithProjection(title, subtitle string, currentLevel, projectedLevel, targetLevel float64) MaturityBullet

NewMaturityBulletWithProjection creates a bullet chart with current and projected levels.

type MaturityBulletData

type MaturityBulletData struct {
	Bullets []MaturityBullet `json:"bullets"`
}

MaturityBulletData holds a collection of maturity bullet charts.

func (*MaturityBulletData) ToJSON

func (d *MaturityBulletData) ToJSON() ([]byte, error)

ToJSON returns the bullet data as JSON for JavaScript consumption.

type MetricConfig

type MetricConfig struct {
	ValueField    string           `json:"valueField"`
	Format        string           `json:"format"`
	FormatOptions *FormatOptions   `json:"formatOptions,omitempty"`
	Thresholds    []ThresholdValue `json:"thresholds,omitempty"`
	Subtitle      string           `json:"subtitle,omitempty"`
}

MetricConfig configures a metric widget.

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

Position defines widget grid position.

type SLIToCapabilityIndex

type SLIToCapabilityIndex map[string][]string

SLIToCapabilityIndex maps SLI IDs to capability IDs that reference them.

type Style

type Style struct {
	Color        string   `json:"color,omitempty"`
	BorderRadius any      `json:"borderRadius,omitempty"`
	BarWidth     any      `json:"barWidth,omitempty"`
	Opacity      *float64 `json:"opacity,omitempty"`
}

Style defines visual styling for marks.

type TableColumn

type TableColumn struct {
	Field  string `json:"field"`
	Header string `json:"header"`
	Width  string `json:"width,omitempty"`
	Align  string `json:"align,omitempty"`
	Format string `json:"format,omitempty"`
}

TableColumn defines a table column.

type TableConfig

type TableConfig struct {
	Columns  []TableColumn `json:"columns"`
	Sortable bool          `json:"sortable,omitempty"`
	Striped  bool          `json:"striped,omitempty"`
}

TableConfig configures a table widget.

type TextConfig

type TextConfig struct {
	Content   string `json:"content"`
	Format    string `json:"format,omitempty"`
	Variables bool   `json:"variables,omitempty"`
}

TextConfig configures a text widget.

type Theme

type Theme struct {
	Mode            string `json:"mode"`
	PrimaryColor    string `json:"primaryColor"`
	BackgroundColor string `json:"backgroundColor,omitempty"`
}

Theme defines dashboard visual styling.

type ThresholdValue

type ThresholdValue struct {
	Value float64 `json:"value"`
	Color string  `json:"color"`
}

ThresholdValue defines a color threshold.

type Tooltip

type Tooltip struct {
	Show    bool   `json:"show"`
	Trigger string `json:"trigger,omitempty"`
}

Tooltip configures chart tooltips.

type Widget

type Widget struct {
	ID           string          `json:"id"`
	Type         string          `json:"type"`
	Title        string          `json:"title"`
	Position     Position        `json:"position"`
	DataSourceID string          `json:"dataSourceId,omitempty"`
	Config       json.RawMessage `json:"config"`
}

Widget represents a dashboard widget.

Jump to

Keyboard shortcuts

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