Go to file
2016-07-16 22:56:12 -07:00
drawing some report card feedback. 2016-07-15 13:40:24 -07:00
examples examples, some fixes 2016-07-16 20:53:46 -07:00
images adding image. 2016-07-15 16:58:27 -07:00
.travis.yml fixing bug with annotations with axis turned off. 2016-07-10 16:26:18 -07:00
annotation_series_test.go more gofmt -s changes. 2016-07-15 13:45:33 -07:00
annotation_series.go examples, some fixes 2016-07-16 20:53:46 -07:00
axis.go gridlines. 2016-07-12 19:14:14 -07:00
bollinger_band_series_test.go adding GetLastBoundedValue and tests 2016-07-15 13:27:45 -07:00
bollinger_band_series.go adding a helper method, DrawBoundedSeries to help w/ bounded series drawing. 2016-07-15 17:15:06 -07:00
box_test.go removing point, adding tests. 2016-07-12 19:38:24 -07:00
box.go slightly more rigorous bounds checking and auto-fit 2016-07-12 16:47:52 -07:00
chart_test.go tests for some things that came up as regressions when building out examples. 2016-07-16 22:56:12 -07:00
chart.go tests for some things that came up as regressions when building out examples. 2016-07-16 22:56:12 -07:00
continuous_series.go mostly works. 2016-07-10 10:43:04 -07:00
defaults.go examples, some fixes 2016-07-16 20:53:46 -07:00
drawing_helpers.go examples, some fixes 2016-07-16 20:53:46 -07:00
exp_moving_average_series_test.go exp. last value and test. 2016-07-16 13:25:21 -07:00
exp_moving_average_series.go exp. last value and test. 2016-07-16 13:25:21 -07:00
grid_line_test.go gofmt -s 2016-07-15 13:43:53 -07:00
grid_line.go pulling generate grid lines into its own function 2016-07-12 19:22:02 -07:00
LICENSE license and readme. 2016-07-07 20:37:57 -07:00
range_test.go bug fixes and refinements. 2016-07-11 23:32:31 -07:00
range.go tests for some things that came up as regressions when building out examples. 2016-07-16 22:56:12 -07:00
raster_renderer.go fixing dashes. 2016-07-14 18:53:54 -07:00
README.md Update README.md 2016-07-16 21:21:50 -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 ??? 2016-07-11 18:48:51 -07:00
ring_buffer_test.go moving averages! dashes! 2016-07-14 09:27:23 -07:00
ring_buffer.go moving averages! dashes! 2016-07-14 09:27:23 -07:00
roboto.go initial commit. 2016-07-06 18:54:00 -07:00
series.go adding GetName() to the series interface 2016-07-14 16:31:26 -07:00
simple_moving_average_series_test.go exp moving average, renaming moving average to simple moving average. 2016-07-16 13:10:44 -07:00
simple_moving_average_series.go exp moving average, renaming moving average to simple moving average. 2016-07-16 13:10:44 -07:00
style_test.go inching up coverage. 2016-07-10 23:06:14 -07:00
style.go fixing dash arrays and style handling in vector renderer. 2016-07-15 18:19:29 -07:00
tick_test.go bug fixes and refinements. 2016-07-11 23:32:31 -07:00
tick.go some regression tests 2016-07-13 11:50:22 -07:00
time_series_test.go updates 2016-07-09 20:14:11 -07:00
time_series.go some regression tests 2016-07-13 11:50:22 -07:00
util_test.go adding tests. 2016-07-14 12:30:57 -07:00
util.go tests. 2016-07-15 09:17:51 -07:00
value_formatter_provider.go mostly works. 2016-07-10 10:43:04 -07:00
value_formatter_test.go inching up coverage. 2016-07-10 23:06:14 -07:00
value_formatter.go adding percent value format 2016-07-14 11:21:41 -07:00
value_provider.go bollinger bounds 2016-07-15 09:02:50 -07:00
vector_renderer_test.go slightly more rigorous bounds checking and auto-fit 2016-07-12 16:47:52 -07:00
vector_renderer.go fixing dash arrays and style handling in vector renderer. 2016-07-15 18:19:29 -07:00
xaxis_test.go more gofmt -s changes. 2016-07-15 13:45:33 -07:00
xaxis.go coverage at 63.8% 2016-07-12 22:04:30 -07:00
yaxis_test.go more gofmt -s changes. 2016-07-15 13:45:33 -07:00
yaxis.go updates 2016-07-12 22:55:46 -07:00

go-chart

Build Status

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.

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:

Simple Moving Average:

Bollinger Bounds:

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.