diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 22:55:26 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 22:55:26 +0200 |
| commit | 78e9de77d8c443fe8dbe560b5ccb168a6142eb55 (patch) | |
| tree | b18f0e45c2bac79b36466ca291ba118a3b8b0f78 /internal/flamegraph/svgwriter.go | |
| parent | 6a761bac0d866f2f3a3b224b603446630803e362 (diff) | |
add docs
Diffstat (limited to 'internal/flamegraph/svgwriter.go')
| -rw-r--r-- | internal/flamegraph/svgwriter.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/flamegraph/svgwriter.go b/internal/flamegraph/svgwriter.go index a2bc3ed..9cdb441 100644 --- a/internal/flamegraph/svgwriter.go +++ b/internal/flamegraph/svgwriter.go @@ -24,6 +24,11 @@ var fnv32aPool = sync.Pool{ }, } +// SVGConfig controls the layout and styling of generated flamegraph SVGs. +// +// Width is the virtual canvas width in pixels, FrameHeight is the height of each +// stack frame row, FontSize is the base font size, and MinWidthPx controls the +// minimum rendered width for a frame (smaller frames are skipped to avoid noise). type SVGConfig struct { Title string Width int @@ -42,6 +47,11 @@ func defaultSVGConfig() SVGConfig { } } +// WriteSVG renders a flamegraph trie into an interactive SVG document. +// +// The output is a self-contained SVG that includes embedded CSS and JavaScript +// for zoom, search, and highlighting, and is designed to be served directly to +// a browser (for example via ServeSVG) without any external assets. func WriteSVG(w io.Writer, t *trie, cfg SVGConfig) error { if cfg.Width <= 0 || cfg.FrameHeight <= 0 || cfg.FontSize <= 0 || cfg.MinWidthPx <= 0 { cfg = defaultSVGConfig() |
