A lightweight, beautiful charting library for Go Terminal User Interfaces (TUIs). Built to work seamlessly with the Charm.sh ecosystem.
- ๐จ 10 Chart Types - Line, Bar, Pie, Doughnut, Scatter, Bubble, Radar, Polar Area, Funnel, and KPI Cards
- ๐ฏ Zero Dependencies - Pure Unicode rendering using Braille patterns (
โฃฟ) and block characters (โ) - ๐ Responsive Design - Auto-scaling with terminal window resizes
- ๐ Declarative API - Simple, chainable methods for quick setup
- ๐ญ Customizable Themes - Cyberpunk aesthetics with full color control
- ๐งฉ Bubble Tea Native - All components implement
tea.Modelinterface - โก High Performance - Efficient rendering for real-time data visualization
go get github.com/aayanmtn/chartgopackage main
import (
"fmt"
"github.com/aayanmtn/chartgo/components"
)
func main() {
// Create a simple line chart
data := []float64{10, 25, 15, 40, 30, 55, 45}
chart := components.NewLineChart(data).
SetWidth(40).
SetHeight(10).
SetTitle("Server Response Time")
fmt.Println(chart.View())
}Output:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Server Response Time โ
โ 55 โกคโ คโขคโก โ
โ 50 โ โ โ โ นโกโขโก โ
โ 45 โ โ โ โ โ โ โ โขฆ โ
โ 40 โขโ โ โ โ โ โ โ โ ฑโก โ
โ 35 โกโขฃโ โ โ โ โ โ โ โ โข โ
โ 30 โ โ โ โ ขโกโ โ โ โ โ โ โ โก โ
โ 25 โ โ โ โ โ โ โ ขโฃโ โ โ โ โ โ โข โ
โ 10 โกโ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โขฆ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Display single metrics with elegant formatting.
kpi := components.NewKPICard("CPU Usage", "85%").
SetWidth(20)
fmt.Println(kpi.View())Output:
โญโโโโโโโโโโโโโโโโโโโฎ
โ CPU Usage โ
โ 85% โ
โฐโโโโโโโโโโโโโโโโโโโฏ
Smooth time-series visualization using Braille patterns for high resolution.
data := []float64{10, 25, 15, 40, 30, 55, 45, 60, 50, 70}
chart := components.NewLineChart(data).
SetWidth(40).
SetHeight(8).
SetTitle("Server Response Time")
fmt.Println(chart.View())Uses Braille characters for 2ร4 sub-pixel resolution per character, creating smooth curves.
Categorical data comparison using block characters.
data := []float64{85, 72, 65, 48, 30}
labels := []string{"Chrome", "Node.js", "Docker", "Slack", "VSCode"}
chart := components.NewBarChart(data, labels).
SetWidth(50).
SetTitle("Process CPU %")
fmt.Println(chart.View())Visualize conversion funnels and pipelines.
data := []float64{1000, 750, 400, 200, 50}
labels := []string{"Visitors", "Signups", "Trials", "Paid", "Enterprise"}
chart := components.NewFunnelChart(data, labels).
SetWidth(50).
SetTitle("Conversion Funnel")
fmt.Println(chart.View())Proportional data representation with legend.
data := []float64{45, 25, 15, 10, 5}
labels := []string{"API", "Database", "Cache", "Auth", "Other"}
chart := components.NewPieChart(data, labels).
SetWidth(40).
SetTitle("Request Distribution")
fmt.Println(chart.View())Plot individual data points with Braille precision.
data := []components.Point{
{X: 1, Y: 2}, {X: 2, Y: 4}, {X: 3, Y: 3},
{X: 4, Y: 5}, {X: 5, Y: 4}, {X: 6, Y: 6},
}
chart := components.NewScatterChart(data).
SetWidth(30).
SetHeight(10).
SetTitle("Data Points")
fmt.Println(chart.View())Multi-dimensional data with variable-sized bubbles.
data := []components.BubblePoint{
{X: 1, Y: 3, Size: 10}, {X: 3, Y: 5, Size: 20},
{X: 5, Y: 2, Size: 15}, {X: 7, Y: 6, Size: 25},
}
chart := components.NewBubbleChart(data).
SetWidth(30).
SetHeight(10).
SetMaxRadius(6).
SetTitle("Performance Metrics")
fmt.Println(chart.View())Spider/web chart for multi-dimensional comparisons.
data := []float64{85, 70, 90, 60, 75}
labels := []string{"Speed", "Power", "Range", "Armor", "Magic"}
chart := components.NewRadarChart(data, labels).
SetWidth(20).
SetHeight(10).
SetTitle("Character Stats")
fmt.Println(chart.View())Ring-shaped proportional visualization.
data := []float64{40, 30, 20, 10}
labels := []string{"React", "Vue", "Angular", "Svelte"}
chart := components.NewDoughnutChart(data, labels).
SetWidth(20).
SetHeight(10).
SetTitle("Framework Usage")
fmt.Println(chart.View())Radial chart with variable segment sizes.
data := []float64{50, 75, 60, 90, 45}
labels := []string{"Jan", "Feb", "Mar", "Apr", "May"}
chart := components.NewPolarAreaChart(data, labels).
SetWidth(20).
SetHeight(10).
SetTitle("Monthly Sales")
fmt.Println(chart.View())All components are native Bubble Tea models and can be used directly in your TUI applications:
package main
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/aayanmtn/chartgo/components"
)
type model struct {
chart *components.LineChart
data []float64
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
if msg.String() == "q" {
return m, tea.Quit
}
case tea.WindowSizeMsg:
m.chart.SetWidth(msg.Width).SetHeight(msg.Height / 2)
}
return m, nil
}
func (m model) View() string {
return m.chart.View()
}
func main() {
data := []float64{10, 25, 15, 40, 30, 55, 45}
p := tea.NewProgram(model{
chart: components.NewLineChart(data).SetTitle("Live Data"),
data: data,
})
p.Run()
}Customize colors and styles using Lip Gloss:
import (
"github.com/charmbracelet/lipgloss"
"github.com/aayanmtn/chartgo/components"
)
customStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("#FF6600")).
Bold(true)
chart := components.NewLineChart(data).
SetStyle(customStyle).
SetTitle("Custom Styled Chart")All charts support chainable configuration:
| Method | Description | Applies To |
|---|---|---|
SetWidth(int) |
Set chart width in characters | All components |
SetHeight(int) |
Set chart height | Line, Scatter, Bubble, Radar |
SetTitle(string) |
Set chart title | All components |
SetData([]float64) |
Update chart data | All components |
SetLabels([]string) |
Set axis/category labels | Bar, Funnel, Pie, Radar, etc. |
SetShowValues(bool) |
Toggle value labels | Bar, Funnel |
SetStyle(lipgloss.Style) |
Custom text styling | All components |
SetBorderStyle(lipgloss.Style) |
Custom border styling | All components |
SetMaxRadius(int) |
Maximum bubble size | Bubble chart |
Default cyberpunk theme:
| Color | Hex | Usage |
|---|---|---|
| Cyan | #00FFFF |
Primary lines/bars |
| Purple | #9D4EDD |
Secondary elements |
| Magenta | #FF00FF |
Highlights |
| Neon Green | #39FF14 |
Accents |
| Pink | #FF6EC7 |
Alternative highlights |
chartgo/
โโโ canvas/ # Rendering engine
โ โโโ canvas.go # Braille canvas with Bresenham's algorithm
โโโ components/ # Chart implementations
โ โโโ barchart.go # Bar Chart
โ โโโ bubble.go # Bubble Chart
โ โโโ doughnut.go # Doughnut Chart
โ โโโ funnel.go # Funnel Chart
โ โโโ kpi.go # KPI Card
โ โโโ linechart.go # Line Chart
โ โโโ piechart.go # Pie Chart
โ โโโ polararea.go # Polar Area Chart
โ โโโ radar.go # Radar/Spider Chart
โ โโโ scatter.go # Scatter Plot
โโโ styles/ # Theming system
โ โโโ theme.go # Color palette definitions
โโโ utils/ # Helper functions
โ โโโ math.go # Mathematical utilities
โโโ examples/ # Demo applications
โโโ main.go # Interactive dashboard example
See all chart types in action with the interactive demo:
git clone https://github.com/aayanmtn/chartgo.git
cd chartgo
go run ./examples/Controls:
- Press
qto quit
The demo showcases real-time updates, multiple chart types, and responsive layouts.
ChartGo uses a sophisticated Braille-based rendering system:
- Sub-pixel Precision: Each terminal character represents a 2ร4 pixel grid
- Unicode Range: U+2800 to U+28FF (256 possible patterns per character)
- Line Drawing: Bresenham's algorithm for smooth, anti-aliased lines
- Circle Rendering: Midpoint circle algorithm for bubbles and radial charts
- Bounds Checking: Safe coordinate handling prevents rendering errors
- Zero Allocations in hot paths during rendering
- Efficient Data Structures for O(1) pixel lookups
- Optimized String Building for terminal output
- Minimal Dependencies - only Charm.sh ecosystem
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
MIT License - see LICENSE file for details
Built with love using:
- Bubble Tea - The fun, functional TUI framework
- Lip Gloss - Style definitions for nice terminal layouts
Documentation โข Examples โข Report Bug โข Request Feature
Made with โค๏ธ for the terminal