plotpage

package
v0.0.0-...-ffc4fba Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package plotpage provides HTML visualization components for analyzer output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBarChart

func BuildBarChart(cOpts *ChartOpts, labels []string, series []BarSeries, yAxisLabel string) *charts.Bar

BuildBarChart constructs a fully configured go-echarts Bar chart using ChartOpts. If cOpts is nil, DefaultChartOpts() is used.

func BuildLineChart

func BuildLineChart(cOpts *ChartOpts, labels []string, series []LineSeries, yAxisLabel string) *charts.Line

BuildLineChart constructs a fully configured go-echarts Line chart using ChartOpts. If cOpts is nil, DefaultChartOpts() is used.

func BuildPieChart

func BuildPieChart(cOpts *ChartOpts, seriesName string, data []opts.PieData, radius string) *charts.Pie

BuildPieChart constructs a fully configured go-echarts Pie chart using ChartOpts. Uses standard defaults: 600x400 dimensions, bottom legend, 60% radius, "{b}: {c} ({d}%)" label formatter. If cOpts is nil, DefaultChartOpts() is used. If radius is empty, "60%" is used.

func LogoDataURI

func LogoDataURI() template.URL

LogoDataURI returns the logo as a data URI for embedding in HTML.

func RenderAnalyzerPage

func RenderAnalyzerPage(w io.Writer, title, desc string, sections ...Section) error

RenderAnalyzerPage creates a page with default settings and renders it.

Types

type Alert

type Alert struct {
	Title   string
	Message string
	Color   BadgeColor
}

Alert renders an alert/notification box.

func NewAlert

func NewAlert(title, message string, color BadgeColor) *Alert

NewAlert creates a new alert.

func (*Alert) Render

func (a *Alert) Render(w io.Writer) error

Render writes the alert HTML.

type Badge

type Badge struct {
	Text    string
	Variant BadgeVariant
	Color   BadgeColor
}

Badge renders an inline badge/tag.

func NewBadge

func NewBadge(text string) *Badge

NewBadge creates a new badge.

func (*Badge) Render

func (b *Badge) Render(w io.Writer) error

Render writes the badge HTML.

func (*Badge) WithColor

func (b *Badge) WithColor(c BadgeColor) *Badge

WithColor sets the badge color.

type BadgeColor

type BadgeColor string

BadgeColor defines badge colors.

const (
	BadgeDefault BadgeColor = "default"
	BadgeAccent  BadgeColor = "accent"
	BadgeSuccess BadgeColor = "success"
	BadgeWarning BadgeColor = "warning"
	BadgeError   BadgeColor = "error"
	BadgeInfo    BadgeColor = "info"
)

Badge color constants.

type BadgeVariant

type BadgeVariant string

BadgeVariant defines badge styling variants.

const (
	BadgeSolid   BadgeVariant = "solid"
	BadgeSoft    BadgeVariant = "soft"
	BadgeOutline BadgeVariant = "outline"
)

Badge variant constants.

type BarSeries

type BarSeries struct {
	Name  string
	Data  []SeriesData
	Color string // Optional, uses theme if empty.
	Stack string // Optional, stack grouping.
}

BarSeries defines the properties and data for a single bar chart series.

type Card

type Card struct {
	Title    string
	Subtitle string
	Content  Renderable
}

Card renders a card container.

func NewCard

func NewCard(title, subtitle string) *Card

NewCard creates a new card.

func (*Card) Render

func (c *Card) Render(w io.Writer) error

Render writes the card HTML.

func (*Card) WithContent

func (c *Card) WithContent(content Renderable) *Card

WithContent sets the card content.

type ChartOpts

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

ChartOpts provides themed chart options based on the current theme.

func DefaultChartOpts

func DefaultChartOpts() *ChartOpts

DefaultChartOpts returns chart options for the default dark theme.

func NewChartOpts

func NewChartOpts(theme Theme) *ChartOpts

NewChartOpts creates a new ChartOpts with the given theme.

func (*ChartOpts) AxisColor

func (c *ChartOpts) AxisColor() string

AxisColor returns the chart axis color.

func (*ChartOpts) DataZoom

func (c *ChartOpts) DataZoom() []opts.DataZoom

DataZoom returns standard data zoom options.

func (*ChartOpts) Grid

func (c *ChartOpts) Grid() opts.Grid

Grid returns grid options with standard margins.

func (*ChartOpts) GridColor

func (c *ChartOpts) GridColor() string

GridColor returns the chart grid color.

func (*ChartOpts) Init

func (c *ChartOpts) Init(width, height string) opts.Initialization

Init returns initialization options with themed background.

func (*ChartOpts) Legend

func (c *ChartOpts) Legend() opts.Legend

Legend returns legend options with themed text color.

func (*ChartOpts) RadarComponent

func (c *ChartOpts) RadarComponent(indicators []*opts.Indicator, splitNumber int) opts.RadarComponent

RadarComponent returns radar component options with themed colors.

func (*ChartOpts) TextColor

func (c *ChartOpts) TextColor() string

TextColor returns the primary chart text color.

func (*ChartOpts) TextMutedColor

func (c *ChartOpts) TextMutedColor() string

TextMutedColor returns the muted chart text color.

func (*ChartOpts) Title

func (c *ChartOpts) Title(title, subtitle string) opts.Title

Title returns title options with themed text colors.

func (*ChartOpts) Tooltip

func (c *ChartOpts) Tooltip(trigger string) opts.Tooltip

Tooltip returns tooltip options.

func (*ChartOpts) XAxis

func (c *ChartOpts) XAxis(name string) opts.XAxis

XAxis returns x-axis options with themed colors.

func (*ChartOpts) YAxis

func (c *ChartOpts) YAxis(name string) opts.YAxis

YAxis returns y-axis options with themed colors.

type ChartPalette

type ChartPalette struct {
	Primary   []string // Main series colors.
	Secondary []string // Secondary/accent colors.
	Semantic  struct {
		Good    string
		Warning string
		Bad     string
	}
}

ChartPalette returns a consistent color palette for charts.

func GetChartPalette

func GetChartPalette(theme Theme) ChartPalette

GetChartPalette returns the chart color palette for a given theme.

type ChartWrapper

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

ChartWrapper wraps an echarts chart and renders only the chart content.

func WrapChart

func WrapChart(chart Renderable) *ChartWrapper

WrapChart wraps an echarts chart to render only the div and script (no full HTML page).

func (*ChartWrapper) Render

func (cw *ChartWrapper) Render(w io.Writer) error

Render writes the chart element and script without a full HTML page.

type Grid

type Grid struct {
	Columns int
	Gap     string
	Items   []Renderable
}

Grid renders a responsive grid layout.

func NewGrid

func NewGrid(columns int, items ...Renderable) *Grid

NewGrid creates a new grid layout.

func (*Grid) Render

func (g *Grid) Render(w io.Writer) error

Render writes the grid HTML.

type HTMLRenderer

type HTMLRenderer struct {
	ExtraCSS string
}

HTMLRenderer renders pages as HTML.

func (HTMLRenderer) Render

func (r HTMLRenderer) Render(w io.Writer, page *Page) error

Render writes the page as HTML to the writer.

type Hint

type Hint struct {
	Title string
	Items []string
}

Hint contains interpretive guidance for a chart section.

type LineSeries

type LineSeries struct {
	Name        string
	Data        []SeriesData
	Color       string  // Optional, uses theme if empty.
	Stack       string  // Optional, stack grouping.
	AreaOpacity float32 // Optional, area opacity for area charts.
}

LineSeries defines the properties and data for a single line chart series.

type MultiPageRenderer

type MultiPageRenderer struct {
	OutputDir string // Directory to write HTML files into.
	Title     string // Project/report title shown on every page.
	Theme     Theme  // ThemeDark or ThemeLight.
}

MultiPageRenderer produces per-analyzer HTML pages plus an index page.

func (*MultiPageRenderer) RebuildIndex

func (r *MultiPageRenderer) RebuildIndex() error

RebuildIndex scans outputDir for *.html files (excluding index.html), derives page metadata from filenames, and regenerates index.html. This is useful after multiple renderers write pages to the same directory.

func (*MultiPageRenderer) RenderAnalyzerPage

func (r *MultiPageRenderer) RenderAnalyzerPage(id, title string, sections []Section) error

RenderAnalyzerPage renders a single analyzer page to <OutputDir>/<id>.html. Each page is standalone HTML with echarts + tailwind CDN and a navigation link back to index.html.

func (*MultiPageRenderer) RenderIndex

func (r *MultiPageRenderer) RenderIndex(pages []PageMeta) error

RenderIndex renders an index page with navigation cards to <OutputDir>/index.html.

type Page

type Page struct {
	Title           string
	Description     string
	ProjectName     string
	ProjectSubtitle string
	ShowThemeToggle bool
	Style           Style
	Theme           Theme
	Sections        []Section
}

Page represents a complete visualization page.

func NewPage

func NewPage(title, description string) *Page

NewPage creates a new visualization page.

func (*Page) Add

func (p *Page) Add(sections ...Section)

Add appends sections to the page.

func (*Page) Render

func (p *Page) Render(w io.Writer) error

Render writes the page as HTML.

type PageMeta

type PageMeta struct {
	ID          string // Filename stem, e.g. "devs", "couples".
	Title       string // Display title, e.g. "Developer Contributions".
	Description string // Short description for the index card.
}

PageMeta carries metadata about a rendered analyzer page for the index.

type Renderable

type Renderable interface {
	Render(w io.Writer) error
}

Renderable is the interface for chart components.

type Section

type Section struct {
	Title    string
	Subtitle string
	Hint     Hint
	Chart    Renderable
}

Section represents a chart section within a page.

type SeriesData

type SeriesData any

SeriesData represents a single numeric value in a chart series. We use any to allow both int and float64 (to map to opts.BarData/opts.LineData).

type Stat

type Stat struct {
	Label string
	Value string
	Trend string
	Color BadgeColor
}

Stat renders a statistic/metric display.

func NewStat

func NewStat(label, value string) *Stat

NewStat creates a new stat display.

func (*Stat) Render

func (s *Stat) Render(w io.Writer) error

Render writes the stat HTML.

func (*Stat) WithTrend

func (s *Stat) WithTrend(trend string, color BadgeColor) *Stat

WithTrend sets the trend indicator.

type Style

type Style struct {
	Width      string
	Height     string
	GridLeft   string
	GridRight  string
	GridTop    string
	GridBottom string
}

Style defines chart dimensions and grid margins.

func DefaultStyle

func DefaultStyle() Style

DefaultStyle returns the default chart style.

type TabItem

type TabItem struct {
	ID      string
	Label   string
	Content Renderable
}

TabItem represents a single tab in a tab group.

type Table

type Table struct {
	Headers []string
	Rows    [][]string
	Striped bool
}

Table renders an HTML table.

func NewTable

func NewTable(headers []string) *Table

NewTable creates a new table.

func (*Table) AddRow

func (t *Table) AddRow(cells ...string) *Table

AddRow adds a row to the table.

func (*Table) Render

func (t *Table) Render(w io.Writer) error

Render writes the table HTML.

func (*Table) WithStriped

func (t *Table) WithStriped(striped bool) *Table

WithStriped enables/disables striping.

type Tabs

type Tabs struct {
	ID    string
	Items []TabItem
}

Tabs renders a tabbed interface.

func NewTabs

func NewTabs(id string, items ...TabItem) *Tabs

NewTabs creates a new tab group.

func (*Tabs) Render

func (t *Tabs) Render(w io.Writer) error

Render writes the tabs HTML.

type Text

type Text struct {
	Content string
}

Text renders plain text content.

func NewText

func NewText(content string) *Text

NewText creates a new text block.

func (*Text) Render

func (t *Text) Render(w io.Writer) error

Render writes the text content.

type Theme

type Theme string

Theme represents a color theme for visualizations.

const (
	// ThemeLight is the light color theme.
	ThemeLight Theme = "light"
	// ThemeDark is the dark color theme.
	ThemeDark Theme = "dark"
)

type ThemeConfig

type ThemeConfig struct {
	// Base colors.
	Background   string
	Surface      string
	SurfaceHover string
	Border       string
	BorderSubtle string

	// Text colors.
	TextPrimary   string
	TextSecondary string
	TextMuted     string

	// Accent colors (brown palette matching Radix UI).
	Accent       string
	AccentHover  string
	AccentSubtle string
	AccentText   string

	// Semantic colors.
	Success       string
	SuccessSubtle string
	Warning       string
	WarningSubtle string
	Error         string
	ErrorSubtle   string
	Info          string
	InfoSubtle    string

	// Chart-specific.
	ChartBackground string
	ChartGrid       string
	ChartAxis       string
	ChartText       string
	ChartTextMuted  string

	// ECharts theme name.
	EChartsTheme string
}

ThemeConfig holds all theme-specific styling values.

func GetThemeConfig

func GetThemeConfig(theme Theme) ThemeConfig

GetThemeConfig returns the configuration for a given theme.

Jump to

Keyboard shortcuts

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