Go to file
2018-12-06 16:46:27 +01:00
_examples change import paths 2018-12-06 16:46:27 +01:00
_images can rotate text + add y axis names 2016-08-06 21:59:46 -07:00
.circleci copy pasta 2018-10-12 09:24:20 -07:00
drawing change import paths 2018-12-06 16:38:58 +01:00
matrix Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
roboto Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
seq change import paths 2018-12-06 16:38:58 +01:00
util adds a rerender example 2018-10-11 17:18:46 -07:00
.gitignore removing coverage artifact 2018-10-12 09:23:56 -07:00
annotation_series_test.go change import paths 2018-12-06 16:38:58 +01:00
annotation_series.go change import paths 2018-12-06 16:38:58 +01:00
axis.go can just supply inverted ranges. 2017-01-09 17:57:45 -08:00
bar_chart_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
bar_chart.go change import paths 2018-12-06 16:38:58 +01:00
bollinger_band_series_test.go change import paths 2018-12-06 16:38:58 +01:00
bollinger_band_series.go change import paths 2018-12-06 16:38:58 +01:00
box_test.go fixing find and replace issue 2018-04-05 00:42:38 -07:00
box.go change import paths 2018-12-06 16:38:58 +01:00
chart_test.go change import paths 2018-12-06 16:38:58 +01:00
chart.go change import paths 2018-12-06 16:38:58 +01:00
colors.go change import paths 2018-12-06 16:38:58 +01:00
concat_series_test.go change import paths 2018-12-06 16:38:58 +01:00
concat_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
continuous_range_test.go change import paths 2018-12-06 16:38:58 +01:00
continuous_range.go descending 2017-01-10 13:50:17 -08:00
continuous_series_test.go change import paths 2018-12-06 16:38:58 +01:00
continuous_series.go updates + tests 2018-09-07 12:52:30 -07:00
COVERAGE adds circle ci 2018-10-12 09:23:30 -07:00
defaults.go color maps 2017-04-14 17:43:52 -07:00
draw.go change import paths 2018-12-06 16:38:58 +01:00
ema_series_test.go change import paths 2018-12-06 16:38:58 +01:00
ema_series.go updates + tests 2018-09-07 12:52:30 -07:00
first_value_annotation_test.go updates + tests 2018-09-07 12:52:30 -07:00
first_value_annotation.go updates + tests 2018-09-07 12:52:30 -07:00
font.go change import paths 2018-12-06 16:38:58 +01:00
grid_line_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
grid_line.go changing gridline behavior. 2016-08-11 20:42:25 -07:00
histogram_series_test.go change import paths 2018-12-06 16:38:58 +01:00
histogram_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
image_writer.go adding validation. 2017-02-03 11:26:53 -08:00
jet.go change import paths 2018-12-06 16:38:58 +01:00
last_value_annotation_test.go updates + tests 2018-09-07 12:52:30 -07:00
last_value_annotation.go updates + tests 2018-09-07 12:52:30 -07:00
legend_test.go fixing find and replace issue 2018-04-05 00:42:38 -07:00
legend.go change import paths 2018-12-06 16:38:58 +01:00
LICENSE license and readme. 2016-07-07 20:37:57 -07:00
linear_coefficient_provider.go sequence tweaks, removing market hours anything 2018-09-10 13:08:20 -07:00
linear_regression_series_test.go change import paths 2018-12-06 16:38:58 +01:00
linear_regression_series.go change import paths 2018-12-06 16:38:58 +01:00
linear_series.go sequence tweaks, removing market hours anything 2018-09-10 13:08:20 -07:00
macd_series_test.go fixing find and replace issue 2018-04-05 00:42:38 -07:00
macd_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
Makefile fixing build 2018-10-12 09:26:46 -07:00
min_max_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
pie_chart_test.go fixing find and replace issue 2018-04-05 00:42:38 -07:00
pie_chart.go change import paths 2018-12-06 16:38:58 +01:00
polynomial_regression_series.go change import paths 2018-12-06 16:38:58 +01:00
polynomial_regression_test.go change import paths 2018-12-06 16:38:58 +01:00
PROFANITY adding IntValueFormatter 2018-09-07 11:17:11 -07:00
range.go descending 2017-01-10 13:50:17 -08:00
raster_renderer.go change import paths 2018-12-06 16:38:58 +01:00
README.md switching the build badge 2018-10-12 09:35:03 -07:00
renderable.go api tweaks. 2016-07-14 18:29:06 -07:00
renderer_provider.go snapshot. 2016-07-10 01:11:47 -07:00
renderer.go change import paths 2018-12-06 16:38:58 +01:00
series.go adding validation. 2017-02-03 11:26:53 -08:00
sma_series_test.go change import paths 2018-12-06 16:38:58 +01:00
sma_series.go change import paths 2018-12-06 16:38:58 +01:00
stacked_bar_chart.go change import paths 2018-12-06 16:38:58 +01:00
style_test.go change import paths 2018-12-06 16:38:58 +01:00
style.go change import paths 2018-12-06 16:38:58 +01:00
text_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
text.go change import paths 2018-12-06 16:38:58 +01:00
tick_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
tick.go change import paths 2018-12-06 16:38:58 +01:00
time_series_test.go fixing find and replace issue 2018-04-05 00:42:38 -07:00
time_series.go change import paths 2018-12-06 16:38:58 +01:00
value_formatter_provider.go mostly works. 2016-07-10 10:43:04 -07:00
value_formatter_test.go change import paths 2018-12-06 16:38:58 +01:00
value_formatter.go adding IntValueFormatter 2018-09-07 11:17:11 -07:00
value_provider.go change import paths 2018-12-06 16:38:58 +01:00
value_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
value.go change import paths 2018-12-06 16:38:58 +01:00
vector_renderer_test.go change import paths 2018-12-06 16:38:58 +01:00
vector_renderer.go change import paths 2018-12-06 16:38:58 +01:00
viridis.go change import paths 2018-12-06 16:38:58 +01:00
xaxis_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
xaxis.go change import paths 2018-12-06 16:38:58 +01:00
yaxis_test.go Fixed order of arguments to assert.Len in test files. (#93) 2018-09-05 08:45:19 -07:00
yaxis.go change import paths 2018-12-06 16:38:58 +01:00

go-chart

CircleCI Go 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.