Add bar chart type #1

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

Motivation

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

Use case from lofigui example 02

// Fibonacci bar chart — grows one bar per second
fib := []float64{1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
labels := []string{"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10"}
for _, n := range []int{2, 4, 6, 8, 10} {
    svg := barChartSVG(fib[:n], labels[:n], fmt.Sprintf("Fibonacci (n=%d)", n))
    lofigui.HTML(svg)
    app.Sleep(1 * time.Second)
}

Required features

  • Vertical bars with category labels on x-axis
  • Value labels above each bar
  • Title
  • Auto-scaled y-axis
  • Configurable size
  • RenderString() output for embedding in lofigui HTML

Suggested API

chart := gogal.NewBarChart(
    gogal.WithTitle("Fibonacci (n=10)"),
    gogal.WithSize(500, 220),
)
chart.Add("Fibonacci", labels, values)
svg, _ := chart.RenderString()

This is listed as Phase 1 in the ROADMAP.


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

## Motivation lofigui example 02 (Output Showcase) currently hand-builds bar charts as inline SVG strings. Switching to gogal requires a bar chart type. ## Use case from lofigui example 02 ```go // Fibonacci bar chart — grows one bar per second fib := []float64{1, 1, 2, 3, 5, 8, 13, 21, 34, 55} labels := []string{"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10"} for _, n := range []int{2, 4, 6, 8, 10} { svg := barChartSVG(fib[:n], labels[:n], fmt.Sprintf("Fibonacci (n=%d)", n)) lofigui.HTML(svg) app.Sleep(1 * time.Second) } ``` ## Required features - Vertical bars with category labels on x-axis - Value labels above each bar - Title - Auto-scaled y-axis - Configurable size - `RenderString()` output for embedding in lofigui HTML ## Suggested API ```go chart := gogal.NewBarChart( gogal.WithTitle("Fibonacci (n=10)"), gogal.WithSize(500, 220), ) chart.Add("Fibonacci", labels, values) svg, _ := chart.RenderString() ``` This is listed as Phase 1 in the ROADMAP. --- *Migrated from Codeberg: originally [#1](https://codeberg.org/hum3/gogal/issues/1), 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#1
No description provided.