Add pie chart type #2

Open
opened 2026-08-07 14:23:03 +00:00 by hum3 · 0 comments
Owner

Motivation

lofigui example 02 (Output Showcase) currently hand-builds pie charts as inline SVG strings. Switching to gogal requires a pie chart type.

Use case from lofigui example 02

slices := []pieSlice{
    {"Go", 35, "#3298dc"},
    {"Python", 28, "#48c774"},
    {"Rust", 18, "#f14668"},
    {"JS", 12, "#ffdd57"},
    {"Other", 7, "#b86bff"},
}
svg := pieChartSVG(slices, "Language Popularity")
lofigui.HTML(svg)

Required features

  • Pie slices with proportional sizing
  • Legend with labels and percentages
  • Title
  • Configurable colours per slice
  • RenderString() output for embedding in lofigui HTML

Suggested API

chart := gogal.NewPieChart(
    gogal.WithTitle("Language Popularity"),
    gogal.WithSize(450, 300),
)
chart.AddSlice("Go", 35)
chart.AddSlice("Python", 28)
chart.AddSlice("Rust", 18)
chart.AddSlice("JS", 12)
chart.AddSlice("Other", 7)
svg, _ := chart.RenderString()

This is listed as Phase 3 in the ROADMAP.


Migrated from Codeberg: originally #2, opened 2026-04-06.

## Motivation lofigui example 02 (Output Showcase) currently hand-builds pie charts as inline SVG strings. Switching to gogal requires a pie chart type. ## Use case from lofigui example 02 ```go slices := []pieSlice{ {"Go", 35, "#3298dc"}, {"Python", 28, "#48c774"}, {"Rust", 18, "#f14668"}, {"JS", 12, "#ffdd57"}, {"Other", 7, "#b86bff"}, } svg := pieChartSVG(slices, "Language Popularity") lofigui.HTML(svg) ``` ## Required features - Pie slices with proportional sizing - Legend with labels and percentages - Title - Configurable colours per slice - `RenderString()` output for embedding in lofigui HTML ## Suggested API ```go chart := gogal.NewPieChart( gogal.WithTitle("Language Popularity"), gogal.WithSize(450, 300), ) chart.AddSlice("Go", 35) chart.AddSlice("Python", 28) chart.AddSlice("Rust", 18) chart.AddSlice("JS", 12) chart.AddSlice("Other", 7) svg, _ := chart.RenderString() ``` This is listed as Phase 3 in the ROADMAP. --- *Migrated from Codeberg: originally [#2](https://codeberg.org/hum3/gogal/issues/2), opened 2026-04-06.*
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hum3/gogal#2
No description provided.