Documentation
¶
Overview ¶
Package plotpage provides HTML visualization components for analyzer output.
Index ¶
- func BuildBarChart(cOpts *ChartOpts, labels []string, series []BarSeries, yAxisLabel string) *charts.Bar
- func BuildLineChart(cOpts *ChartOpts, labels []string, series []LineSeries, yAxisLabel string) *charts.Line
- func BuildPieChart(cOpts *ChartOpts, seriesName string, data []opts.PieData, radius string) *charts.Pie
- func LogoDataURI() template.URL
- func RenderAnalyzerPage(w io.Writer, title, desc string, sections ...Section) error
- type Alert
- type Badge
- type BadgeColor
- type BadgeVariant
- type BarSeries
- type Card
- type ChartOpts
- func (c *ChartOpts) AxisColor() string
- func (c *ChartOpts) DataZoom() []opts.DataZoom
- func (c *ChartOpts) Grid() opts.Grid
- func (c *ChartOpts) GridColor() string
- func (c *ChartOpts) Init(width, height string) opts.Initialization
- func (c *ChartOpts) Legend() opts.Legend
- func (c *ChartOpts) RadarComponent(indicators []*opts.Indicator, splitNumber int) opts.RadarComponent
- func (c *ChartOpts) TextColor() string
- func (c *ChartOpts) TextMutedColor() string
- func (c *ChartOpts) Title(title, subtitle string) opts.Title
- func (c *ChartOpts) Tooltip(trigger string) opts.Tooltip
- func (c *ChartOpts) XAxis(name string) opts.XAxis
- func (c *ChartOpts) YAxis(name string) opts.YAxis
- type ChartPalette
- type ChartWrapper
- type Grid
- type HTMLRenderer
- type Hint
- type LineSeries
- type MultiPageRenderer
- type Page
- type PageMeta
- type Renderable
- type Section
- type SeriesData
- type Stat
- type Style
- type TabItem
- type Table
- type Tabs
- type Text
- type Theme
- type ThemeConfig
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 ¶
LogoDataURI returns the logo as a data URI for embedding in HTML.
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.
type Badge ¶
type Badge struct {
Text string
Variant BadgeVariant
Color BadgeColor
}
Badge renders an inline badge/tag.
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 (*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 ¶
NewChartOpts creates a new ChartOpts with the given theme.
func (*ChartOpts) Init ¶
func (c *ChartOpts) Init(width, height string) opts.Initialization
Init returns initialization options with themed background.
func (*ChartOpts) RadarComponent ¶
func (c *ChartOpts) RadarComponent(indicators []*opts.Indicator, splitNumber int) opts.RadarComponent
RadarComponent returns radar component options with themed colors.
func (*ChartOpts) TextMutedColor ¶
TextMutedColor returns the muted chart text color.
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).
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.
type HTMLRenderer ¶
type HTMLRenderer struct {
ExtraCSS string
}
HTMLRenderer renders pages as HTML.
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.
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 ¶
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.
type Style ¶
type Style struct {
Width string
Height string
GridLeft string
GridRight string
GridTop string
GridBottom string
}
Style defines chart dimensions and grid margins.
type TabItem ¶
type TabItem struct {
ID string
Label string
Content Renderable
}
TabItem represents a single tab in a tab group.
type Table ¶
Table renders an HTML table.
func (*Table) WithStriped ¶
WithStriped enables/disables striping.
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.