Skip to content
go chart is a basic charting library in native golang.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci copy pasta Oct 12, 2018
_images can rotate text + add y axis names Aug 7, 2016
cmd/chart updates Sep 10, 2019
drawing fixing find and replace issue Apr 5, 2018
examples switching to generators Sep 10, 2019
matrix Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
roboto Helper API refactor (#40) May 13, 2017
.gitignore removing coverage artifact Oct 12, 2018
COVERAGE switching to generators Sep 10, 2019
LICENSE license and readme. Jul 8, 2016
Makefile switching to generators Sep 10, 2019
PROFANITY_RULES.yml removing go-sdk completely Apr 24, 2019
README.md updates Sep 10, 2019
annotation_series.go mostly working Feb 14, 2019
annotation_series_test.go mostly working Feb 14, 2019
array.go mostly working Feb 14, 2019
axis.go can just supply inverted ranges. Jan 10, 2017
bar_chart.go mostly working Feb 14, 2019
bar_chart_test.go mostly working Feb 14, 2019
bollinger_band_series.go mostly working Feb 14, 2019
bollinger_band_series_test.go mostly working Feb 14, 2019
bounded_last_values_annotation_series.go additions Sep 10, 2019
box.go snapshot Feb 14, 2019
box_test.go fixing find and replace issue Apr 5, 2018
chart.go tests pass Feb 16, 2019
chart_test.go adds percent change series Sep 10, 2019
colors.go color maps Apr 15, 2017
concat_series.go Helper API refactor (#40) May 13, 2017
concat_series_test.go mostly working Feb 14, 2019
continuous_range.go mostly working Feb 14, 2019
continuous_range_test.go snapshot Feb 14, 2019
continuous_series.go mostly working Feb 14, 2019
continuous_series_test.go mostly working Feb 14, 2019
defaults.go color maps Apr 15, 2017
donut_chart.go merging master Sep 10, 2019
donut_chart_test.go merging master Sep 10, 2019
draw.go snapshot Feb 14, 2019
ema_series.go updates + tests Sep 7, 2018
ema_series_test.go mostly working Feb 14, 2019
fileutil.go removing go-sdk stuff Apr 24, 2019
first_value_annotation.go updates + tests Sep 7, 2018
first_value_annotation_test.go updates + tests Sep 7, 2018
font.go Helper API refactor (#40) May 13, 2017
grid_line.go changing gridline behavior. Aug 12, 2016
grid_line_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
histogram_series.go Helper API refactor (#40) May 13, 2017
histogram_series_test.go mostly working Feb 14, 2019
image_writer.go adding validation. Feb 3, 2017
jet.go Separation of DotColorProvider and ColorProvider Interfaces (#34) Apr 17, 2017
last_value_annotation_series.go updates Feb 14, 2019
last_value_annotation_series_test.go updates Feb 14, 2019
legend.go mostly working Feb 14, 2019
legend_test.go fixing find and replace issue Apr 5, 2018
linear_coefficient_provider.go sequence tweaks, removing market hours anything Sep 10, 2018
linear_regression_series.go snapshot Feb 14, 2019
linear_regression_series_test.go mostly working Feb 14, 2019
linear_sequence.go mostly working Feb 14, 2019
linear_series.go sequence tweaks, removing market hours anything Sep 10, 2018
logger.go adds percent change series Sep 10, 2019
macd_series.go Helper API refactor (#40) May 13, 2017
macd_series_test.go fixing find and replace issue Apr 5, 2018
mathutil.go snapshot Feb 14, 2019
min_max_series.go Helper API refactor (#40) May 13, 2017
parse.go removing go-sdk stuff Apr 24, 2019
percent_change_series.go adds percent change series Sep 10, 2019
percent_change_series_test.go adds percent change series Sep 10, 2019
pie_chart.go mostly working Feb 14, 2019
pie_chart_test.go fixing find and replace issue Apr 5, 2018
polynomial_regression_series.go snapshot Feb 14, 2019
polynomial_regression_test.go fixing find and replace issue Apr 5, 2018
random_sequence.go mostly working Feb 14, 2019
range.go descending Jan 10, 2017
raster_renderer.go snapshot Feb 14, 2019
renderable.go api tweaks. Jul 15, 2016
renderer.go Add ability to set CSS classes instead of inline styles (#103) Oct 12, 2018
renderer_provider.go snapshot. Jul 10, 2016
seq.go updates Feb 14, 2019
seq_test.go mostly working Feb 14, 2019
series.go adding validation. Feb 3, 2017
sma_series.go snapshot Feb 14, 2019
sma_series_test.go mostly working Feb 14, 2019
stacked_bar_chart.go mostly working Feb 14, 2019
stringutil.go snapshot Feb 14, 2019
stringutil_test.go snapshot Feb 14, 2019
style.go mostly working Feb 14, 2019
style_test.go fixing find and replace issue Apr 5, 2018
text.go snapshot Feb 14, 2019
text_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
tick.go snapshot Feb 14, 2019
tick_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
time_series.go snapshot Feb 14, 2019
time_series_test.go
times.go removing go-sdk completely Apr 24, 2019
timeutil.go mostly working Feb 14, 2019
value.go snapshot Feb 14, 2019
value_buffer.go mostly working Feb 14, 2019
value_buffer_test.go mostly working Feb 14, 2019
value_formatter.go additions Sep 10, 2019
value_formatter_provider.go mostly works. Jul 10, 2016
value_formatter_test.go snapshot Feb 14, 2019
value_provider.go updates + tests Sep 7, 2018
value_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
vector_renderer.go merging master Sep 10, 2019
vector_renderer_test.go Add ability to set custom stylesheets for SVG renderer (#105) Oct 12, 2018
viridis.go Separation of DotColorProvider and ColorProvider Interfaces (#34) Apr 17, 2017
xaxis.go tests pass Feb 16, 2019
xaxis_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018
yaxis.go tests pass Feb 16, 2019
yaxis_test.go Fixed order of arguments to assert.Len in test files. (#93) Sep 5, 2018

README.md

go-chart

CircleCI Go Report Card

Package chart is a very simple golang native charting library that supports timeseries and continuous line charts.

Master should now be on the v3.x codebase, which overhauls the api significantly. Per usual, see examples for more information.

Installation

To install chart run the following:

> go get -u github.com/wcharczuk/go-chart

Most of the components are interchangeable so feel free to crib whatever you want.

Output Examples

Spark Lines:

Single axis:

Two axis:

Other Chart Types

Pie Chart:

The code for this chart can be found in examples/pie_chart/main.go.

Stacked Bar:

The code for this chart can be found in examples/stacked_bar/main.go.

Code Examples

Actual chart configurations and examples can be found in the ./examples/ directory. They are simple CLI programs that write to output.png (they are also updated with go generate.

Usage

Everything starts with the chart.Chart object. The bare minimum to draw a chart would be the following:

import (
    ...
    "bytes"
    ...
    "github.com/wcharczuk/go-chart" //exposes "chart"
)

graph := chart.Chart{
    Series: []chart.Series{
        chart.ContinuousSeries{
            XValues: []float64{1.0, 2.0, 3.0, 4.0},
            YValues: []float64{1.0, 2.0, 3.0, 4.0},
        },
    },
}

buffer := bytes.NewBuffer([]byte{})
err := graph.Render(chart.PNG, buffer)

Explanation of the above: A chart can have many Series, a Series is a collection of things that need to be drawn according to the X range and the Y range(s).

Here, we have a single series with x range values as float64s, rendered to a PNG. Note; we can pass any type of io.Writer into Render(...), meaning that we can render the chart to a file or a resonse or anything else that implements io.Writer.

API Overview

Everything on the chart.Chart object has defaults that can be overriden. Whenever a developer sets a property on the chart object, it is to be assumed that value will be used instead of the default.

The best way to see the api in action is to look at the examples in the ./_examples/ directory.

Design Philosophy

I wanted to make a charting library that used only native golang, that could be stood up on a server (i.e. it had built in fonts).

The goal with the API itself is to have the "zero value be useful", and to require the user to not code more than they absolutely needed.

Contributions

Contributions are welcome though this library is in a holding pattern for the forseable future.

You can’t perform that action at this time.