go-charts

module
v0.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT

README

Go-Charts

CI

Charting library for Go, built on go-gui. Immediate-mode rendering via DrawCanvas — no virtual DOM, no diffing, just fast composable charts.

Showcase

Browse the full chart gallery →

Highlights

  • 18+ chart types covering analytics, statistics, and finance
  • Pure-Go rendering with retained tessellation cache; redraws are free when data is unchanged
  • 16x MSAA PNG and SVG export — no window required
  • Themeable: Tableau 10, Pastel, Vivid, and high-contrast accessibility palettes; customize colors, padding, legends, and tick styles
  • Built-in data transforms: SMA/EMA/WMA, linear and polynomial regression, Bollinger bands, LTTB downsampling, binning
  • CSV and JSON parsers for typed series
  • Linear, Log, Time, and Category axes with auto-tick generation
  • Zoom, pan, and brush select out of the box
  • Zero external runtime dependencies beyond go-gui

Quick Start

package main

import (
    "github.com/mike-ward/go-charts/chart"
    "github.com/mike-ward/go-charts/series"
    "github.com/mike-ward/go-gui/gui"
    "github.com/mike-ward/go-gui/gui/backend"
)

func main() {
    gui.SetTheme(gui.ThemeDarkBordered)
    w := gui.NewWindow(gui.WindowCfg{
        Title:  "Line Chart",
        Width:  800,
        Height: 600,
        OnInit: func(w *gui.Window) { w.UpdateView(view) },
    })
    backend.Run(w)
}

func view(w *gui.Window) gui.View {
    return chart.Line(chart.LineCfg{
        ID: "demo",
        Series: []series.XY{
            series.NewXY(series.XYCfg{
                Name:  "Sales",
                Color: gui.Hex(0x4E79A7),
                Points: []series.Point{
                    {X: 1, Y: 10}, {X: 2, Y: 25},
                    {X: 3, Y: 18}, {X: 4, Y: 32},
                },
            }),
        },
    })
}

Headless Export

Render any chart to PNG or SVG with no window or display:

chart.ExportPNG(view, 960, 600, "chart.png")
chart.ExportSVG(view, 960, 600, "chart.svg")

Showcase

Run the interactive showcase to browse 70+ live demos with source code:

go run ./examples/showcase

Chart Types

Type Function Type Function
Line chart.Line() Box Plot chart.BoxPlot()
Bar chart.Bar() Waterfall chart.Waterfall()
Area chart.Area() Combo chart.Combo()
Scatter chart.Scatter() Radar chart.Radar()
Bubble chart.Bubble() Heatmap chart.Heatmap()
Pie/Donut chart.Pie() Treemap chart.Treemap()
Gauge chart.Gauge() Funnel chart.Funnel()
Candlestick chart.Candlestick() Sankey chart.Sankey()
Histogram chart.Histogram() Sparkline chart.Sparkline()

See doc/ROADMAP.md for planned features.

Packages

Package Description
chart Chart widgets and headless PNG/SVG export
axis Linear, Log, Time, and Category axes with auto-tick generation
series Data types: XY, XYZ, Category, OHLC, Grid, TreeNode + CSV/JSON parsers
scale Data-to-pixel mapping: Linear, Log
theme Color palettes and visual styling
transform Moving averages, regression, envelopes, LTTB, binning
render DrawContext adapter for chart primitives

Requirements

  • Go 1.26+
  • go-gui
  • SDL2 (for the interactive showcase; not required for headless export)

Install

go get github.com/mike-ward/go-charts

Build

go build ./...
go test ./...
go vet ./...
golangci-lint run ./...

License

MIT License

Directories

Path Synopsis
Package axis provides axis types for chart positioning and labeling.
Package axis provides axis types for chart positioning and labeling.
Package chart provides chart widgets for go-gui.
Package chart provides chart widgets for go-gui.
examples
basic_bar command
basic_line command
showcase command
internal
fmath
Package fmath provides shared floating-point helpers.
Package fmath provides shared floating-point helpers.
Package render provides chart rendering helpers wrapping gui.DrawContext.
Package render provides chart rendering helpers wrapping gui.DrawContext.
Package scale provides data-to-pixel mapping transformations.
Package scale provides data-to-pixel mapping transformations.
Package series provides data series types for charts.
Package series provides data series types for charts.
Package theme provides theming for charts.
Package theme provides theming for charts.
Package transform provides pure data transforms for series.XY data: moving averages, regression, envelopes, downsampling, and binning.
Package transform provides pure data transforms for series.XY data: moving averages, regression, envelopes, downsampling, and binning.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL