Go to file
Will Charczuk 674e75d285 snapshot
2017-04-29 22:44:17 -07:00
_examples api cleaup 2017-04-28 16:07:36 -07:00
_images
drawing adding jet as a generator 2017-04-15 09:59:37 -07:00
matrix cow -> col 2017-04-18 23:53:29 -07:00
roboto updates 2017-04-29 16:18:09 -07:00
sequence snapshot 2017-04-29 22:44:17 -07:00
util tweaks 2017-04-29 22:32:45 -07:00
.gitignore
.travis.yml
annotation_series_test.go these tests are not a joke 2017-02-22 17:48:32 -08:00
annotation_series.go updates 2017-04-29 16:18:09 -07:00
axis.go
bar_chart_test.go handle zero values 2017-01-13 14:37:08 -08:00
bar_chart.go updates 2017-04-29 16:18:09 -07:00
bollinger_band_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
bollinger_band_series.go updates 2017-04-29 16:18:09 -07:00
box_test.go Adds the ability to draw an XY scatter plot. (#27) 2017-03-05 16:54:40 -08:00
box.go Adds the ability to draw an XY scatter plot. (#27) 2017-03-05 16:54:40 -08:00
chart_test.go api cleaup 2017-04-28 16:07:36 -07:00
chart.go api cleaup 2017-04-28 16:07:36 -07:00
colors.go color maps 2017-04-14 17:43:52 -07:00
concat_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
concat_series.go api cleaup 2017-04-28 16:07:36 -07:00
continuous_range_test.go
continuous_range.go
continuous_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
continuous_series.go api cleaup 2017-04-28 16:07:36 -07:00
defaults.go color maps 2017-04-14 17:43:52 -07:00
draw.go api cleaup 2017-04-28 16:07:36 -07:00
ema_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
ema_series.go api cleaup 2017-04-28 16:07:36 -07:00
font.go color maps 2017-04-14 17:43:52 -07:00
grid_line_test.go
grid_line.go
histogram_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
histogram_series.go api cleaup 2017-04-28 16:07:36 -07:00
image_writer.go adding validation. 2017-02-03 11:26:53 -08:00
jet.go Separation of DotColorProvider and ColorProvider Interfaces (#34) 2017-04-17 16:21:02 -07:00
last_value_annotation_series.go api cleaup 2017-04-28 16:07:36 -07:00
legend_test.go
legend.go slight tweak to legend (adds a new style) and example 2017-02-13 00:27:02 -08:00
LICENSE
linear_regression_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
linear_regression_series.go api cleaup 2017-04-28 16:07:36 -07:00
macd_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
macd_series.go api cleaup 2017-04-28 16:07:36 -07:00
Makefile
market_hours_range_test.go deferring creating market open times. 2017-02-12 09:10:21 -08:00
market_hours_range.go updates 2017-04-29 16:18:09 -07:00
min_max_series.go api cleaup 2017-04-28 16:07:36 -07:00
pie_chart_test.go
pie_chart.go color maps 2017-04-14 17:43:52 -07:00
polynomial_regression_series.go api cleaup 2017-04-28 16:07:36 -07:00
polynomial_regression_test.go api cleaup 2017-04-28 16:07:36 -07:00
range.go
raster_renderer.go Adds the ability to draw an XY scatter plot. (#27) 2017-03-05 16:54:40 -08:00
README.md
renderable.go
renderer_provider.go
renderer.go
series.go adding validation. 2017-02-03 11:26:53 -08:00
sma_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
sma_series.go api cleaup 2017-04-28 16:07:36 -07:00
stacked_bar_chart.go api cleaup 2017-04-28 16:07:36 -07:00
style_test.go
style.go Separation of DotColorProvider and ColorProvider Interfaces (#34) 2017-04-17 16:21:02 -07:00
text_test.go
text.go
tick_test.go
tick.go sane default handling 2017-04-25 23:35:07 -07:00
time_series_test.go api cleaup 2017-04-28 16:07:36 -07:00
time_series.go api cleaup 2017-04-28 16:07:36 -07:00
value_formatter_provider.go
value_formatter_test.go fixing tests 2017-04-25 20:03:30 -07:00
value_formatter.go ??? 2017-04-25 20:01:48 -07:00
value_provider.go api cleaup 2017-04-28 16:07:36 -07:00
value_test.go
value.go
vector_renderer_test.go
vector_renderer.go adding helper 2017-03-26 16:29:24 -07:00
viridis.go Separation of DotColorProvider and ColorProvider Interfaces (#34) 2017-04-17 16:21:02 -07:00
xaxis_test.go Adds the ability to draw an XY scatter plot. (#27) 2017-03-05 16:54:40 -08:00
xaxis.go sane default handling 2017-04-25 23:35:07 -07:00
yaxis_test.go Adds the ability to draw an XY scatter plot. (#27) 2017-03-05 16:54:40 -08:00
yaxis.go sane default handling 2017-04-25 23:35:07 -07:00

go-chart

Build StatusGo Report Card

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

The v1.0 release has been tagged so things should be more or less stable, if something changes please log an issue.

Master should now be on the v2.x codebase, which brings a couple new features and better handling of basics like axes labeling etc. 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 web servers, so start them with go run main.go then access http://localhost:8080 to see the output.

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. One complication here is any object's root chart.Style object (i.e named Style) and the Show property specifically, if any other property is set and the Show property is unset, it is assumed to be it's default value of False.

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

This library is super early but contributions are welcome.