Documentation
¶
Overview ¶
Package svg provides SVG stats card generation for GitHub profiles.
Index ¶
- Constants
- func CalculateHeight(numRows int) float64
- func ChangelogCategoriesByMonthChart(data *chart.CommitTypeData, themeName, title string) *chart.StackedBarChart
- func ChangelogCategoriesByMonthChartJSON(data *chart.CommitTypeData, themeName, title string) ([]byte, error)
- func ChangelogCategoriesByMonthChartSVG(data *chart.CommitTypeData, themeName, title string) string
- func CommitTypesByMonthChart(data *chart.CommitTypeData, themeName, title string) *chart.StackedBarChart
- func CommitTypesByMonthChartJSON(data *chart.CommitTypeData, themeName, title string) ([]byte, error)
- func CommitTypesByMonthChartSVG(data *chart.CommitTypeData, themeName, title string) string
- func GenerateMonthlyLinesJSON(p *profile.UserProfile, themeName string) ([]byte, error)
- func GenerateMonthlyLinesSVG(p *profile.UserProfile, themeName, title string) string
- func GenerateSVG(p *profile.UserProfile, themeName, title string) string
- func GenerateSVGBytes(p *profile.UserProfile, themeName, title string) []byte
- func MonthlyAdditionsDeletionsBarChart(p *profile.UserProfile, themeName, title string) *chart.BarChart
- func MonthlyLinesBarChart(p *profile.UserProfile, themeName, title string) *chart.BarChart
- func MonthlyLinesBarChartJSON(p *profile.UserProfile, themeName, title string) ([]byte, error)
- func MonthlyLinesBarChartSVG(p *profile.UserProfile, themeName, title string) string
- func ProfileStatsTable(p *profile.UserProfile, themeName, title string) *chart.TableChart
- func ProfileStatsTableJSON(p *profile.UserProfile, themeName, title string) ([]byte, error)
- func ProfileStatsTableSVG(p *profile.UserProfile, themeName, title string) string
- func RenderIcon(iconType IconType, x, y, size float64, color string) string
- func RenderIconInline(iconType IconType, color string) string
- func ThemeNames() []string
- type Card
- func (c *Card) RenderBackground() string
- func (c *Card) RenderFooter() string
- func (c *Card) RenderHeader() string
- func (c *Card) RenderStatRows(rows []StatRow, startY float64) string
- func (c *Card) RenderStyles() string
- func (c *Card) RenderTitle() string
- func (c *Card) RenderTitleText() string
- func (c *Card) SetHeight(height float64)
- type IconType
- type StatRow
- type StatsCard
- type StatsCardOptions
- type Theme
Constants ¶
const ( // DefaultWidth is the default card width in pixels. DefaultWidth = 350 // DefaultPaddingX is the horizontal padding. DefaultPaddingX = 25 // DefaultPaddingY is the vertical padding for the title. DefaultPaddingY = 35 // DefaultBorderRadius is the corner radius. DefaultBorderRadius = 4.5 // DefaultStatRowHeight is the height of each stat row. DefaultStatRowHeight = 25 // DefaultIconSize is the size of stat icons. DefaultIconSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func CalculateHeight ¶
CalculateHeight returns the required height for a card with the given number of stat rows.
func ChangelogCategoriesByMonthChart ¶
func ChangelogCategoriesByMonthChart(data *chart.CommitTypeData, themeName, title string) *chart.StackedBarChart
ChangelogCategoriesByMonthChart creates a stacked bar chart showing changelog categories by month. This is the stakeholder-focused view showing Added, Fixed, Changed, etc.
func ChangelogCategoriesByMonthChartJSON ¶
func ChangelogCategoriesByMonthChartJSON(data *chart.CommitTypeData, themeName, title string) ([]byte, error)
ChangelogCategoriesByMonthChartJSON generates a JSON IR for changelog categories by month.
func ChangelogCategoriesByMonthChartSVG ¶
func ChangelogCategoriesByMonthChartSVG(data *chart.CommitTypeData, themeName, title string) string
ChangelogCategoriesByMonthChartSVG generates an SVG for changelog categories by month.
func CommitTypesByMonthChart ¶
func CommitTypesByMonthChart(data *chart.CommitTypeData, themeName, title string) *chart.StackedBarChart
CommitTypesByMonthChart creates a stacked bar chart showing conventional commit types by month. This is the developer-focused view showing feat, fix, docs, refactor, etc.
func CommitTypesByMonthChartJSON ¶
func CommitTypesByMonthChartJSON(data *chart.CommitTypeData, themeName, title string) ([]byte, error)
CommitTypesByMonthChartJSON generates a JSON IR for commit types by month.
func CommitTypesByMonthChartSVG ¶
func CommitTypesByMonthChartSVG(data *chart.CommitTypeData, themeName, title string) string
CommitTypesByMonthChartSVG generates an SVG for commit types by month.
func GenerateMonthlyLinesJSON ¶
func GenerateMonthlyLinesJSON(p *profile.UserProfile, themeName string) ([]byte, error)
GenerateMonthlyLinesJSON creates the JSON IR for a monthly lines bar chart. Deprecated: Use MonthlyLinesBarChartJSON for the new generic chart API.
func GenerateMonthlyLinesSVG ¶
func GenerateMonthlyLinesSVG(p *profile.UserProfile, themeName, title string) string
GenerateMonthlyLinesSVG creates the SVG for a monthly lines bar chart. Deprecated: Use MonthlyLinesBarChartSVG for the new generic chart API.
func GenerateSVG ¶
func GenerateSVG(p *profile.UserProfile, themeName, title string) string
GenerateSVG is a convenience function to generate an SVG from a profile. Deprecated: Use ProfileStatsTableSVG for the new generic chart API.
func GenerateSVGBytes ¶
func GenerateSVGBytes(p *profile.UserProfile, themeName, title string) []byte
GenerateSVGBytes is a convenience function to generate SVG bytes from a profile. Deprecated: Use ProfileStatsTable(p, theme, title).RenderBytes() for the new generic chart API.
func MonthlyAdditionsDeletionsBarChart ¶
func MonthlyAdditionsDeletionsBarChart(p *profile.UserProfile, themeName, title string) *chart.BarChart
MonthlyAdditionsDeleteionsBarChart creates a multi-series bar chart.
func MonthlyLinesBarChart ¶
func MonthlyLinesBarChart(p *profile.UserProfile, themeName, title string) *chart.BarChart
MonthlyLinesBarChart creates a bar chart showing net lines by month.
func MonthlyLinesBarChartJSON ¶
func MonthlyLinesBarChartJSON(p *profile.UserProfile, themeName, title string) ([]byte, error)
MonthlyLinesBarChartJSON generates a JSON IR for the monthly lines chart.
func MonthlyLinesBarChartSVG ¶
func MonthlyLinesBarChartSVG(p *profile.UserProfile, themeName, title string) string
MonthlyLinesBarChartSVG generates an SVG bar chart from a profile.
func ProfileStatsTable ¶
func ProfileStatsTable(p *profile.UserProfile, themeName, title string) *chart.TableChart
ProfileStatsTable creates a table chart from a UserProfile.
func ProfileStatsTableJSON ¶
func ProfileStatsTableJSON(p *profile.UserProfile, themeName, title string) ([]byte, error)
ProfileStatsTableJSON generates a JSON IR for the stats table.
func ProfileStatsTableSVG ¶
func ProfileStatsTableSVG(p *profile.UserProfile, themeName, title string) string
ProfileStatsTableSVG generates an SVG stats table from a profile.
func RenderIcon ¶
RenderIcon returns an SVG group element containing the icon. The icon is rendered at the specified position with the given size and color.
func RenderIconInline ¶
RenderIconInline returns just the path element for embedding in an existing SVG.
Types ¶
type Card ¶
type Card struct {
Width float64
Height float64
PaddingX float64
PaddingY float64
BorderRadius float64
Theme Theme
Title string
}
Card represents the base SVG card structure.
func (*Card) RenderBackground ¶
RenderBackground returns the background rectangle.
func (*Card) RenderFooter ¶
RenderFooter returns the closing SVG tag.
func (*Card) RenderHeader ¶
RenderHeader returns the SVG header with XML declaration and opening tag.
func (*Card) RenderStatRows ¶
RenderStatRows renders multiple stat rows starting at the given Y position.
func (*Card) RenderStyles ¶
RenderStyles returns the CSS styles block.
func (*Card) RenderTitle ¶
RenderTitle returns the SVG title element.
func (*Card) RenderTitleText ¶
RenderTitleText returns the title text element.
type StatsCard ¶
type StatsCard struct {
*Card
// contains filtered or unexported fields
}
StatsCard generates an SVG stats card from a UserProfile.
func NewStatsCard ¶
func NewStatsCard(p *profile.UserProfile, theme Theme, title string) *StatsCard
NewStatsCard creates a new stats card from a UserProfile.
func NewStatsCardWithOptions ¶
func NewStatsCardWithOptions(p *profile.UserProfile, opts StatsCardOptions) *StatsCard
NewStatsCardWithOptions creates a stats card with custom options.
func (*StatsCard) RenderBytes ¶
RenderBytes returns the SVG as a byte slice.
type StatsCardOptions ¶
type StatsCardOptions struct {
Theme string
Title string
HideBorder bool
HideTitle bool
CustomStats []StatRow // Additional custom stats to include
ExcludeStats []string // Stat labels to exclude
Width float64 // Custom width (0 = default)
BgColor string // Override background color
TitleColor string // Override title color
TextColor string // Override text color
IconColor string // Override icon color
}
StatsCardOptions configures the stats card generation.
type Theme ¶
type Theme struct {
Name string
TitleColor string // hex color for title text
TextColor string // hex color for stat labels and values
IconColor string // hex color for stat icons
BgColor string // hex color for background
BorderColor string // hex color for border
}
Theme defines the color scheme for an SVG stats card.