Go to file
2016-07-30 23:14:19 -07:00
date fixing calculate on day. 2016-07-27 00:34:10 -07:00
drawing text options! 2016-07-29 16:36:29 -07:00
examples tests are pretty helpful 2016-07-30 09:38:43 -07:00
images tests are pretty helpful 2016-07-30 09:38:43 -07:00
.travis.yml travis. 2016-07-28 14:32:23 -07:00
annotation_series_test.go need to flesh out this test more. 2016-07-28 14:30:00 -07:00
annotation_series.go adding back default font color for annotations. 2016-07-30 09:52:18 -07:00
axis.go axis tick position 2016-07-30 09:12:03 -07:00
bollinger_band_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
bollinger_band_series.go axis tick position 2016-07-30 09:12:03 -07:00
box_test.go testing histogram series. 2016-07-28 16:36:30 -07:00
box.go big api overhauls. 2016-07-29 18:24:25 -07:00
chart_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
chart.go big api overhauls. 2016-07-29 18:24:25 -07:00
concat_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
concat_series.go introduces the Range interface (instead of a concrete type). 2016-07-21 14:11:27 -07:00
continuous_range_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
continuous_range.go introduces the Range interface (instead of a concrete type). 2016-07-21 14:11:27 -07:00
continuous_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
continuous_series.go axis tick position 2016-07-30 09:12:03 -07:00
defaults.go examples. 2016-07-29 23:31:49 -07:00
draw.go changing how Draw.LineSeries handles the 0 line 2016-07-30 23:14:19 -07:00
ema_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
ema_series.go axis tick position 2016-07-30 09:12:03 -07:00
grid_line_test.go fixing test. 2016-07-26 23:55:31 -07:00
grid_line.go market hours range not quite working yet. 2016-07-24 22:54:03 -07:00
histogram_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
histogram_series.go axis tick position 2016-07-30 09:12:03 -07:00
legend.go big api overhauls. 2016-07-29 18:24:25 -07:00
LICENSE license and readme. 2016-07-07 20:37:57 -07:00
linear_regression_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
linear_regression_series.go axis tick position 2016-07-30 09:12:03 -07:00
macd_series_test.go fixing macd inversion. 2016-07-18 17:41:59 -07:00
macd_series.go axis tick position 2016-07-30 09:12:03 -07:00
Makefile testing histogram series. 2016-07-28 16:36:30 -07:00
market_hours_range_test.go fixing market hours 2016-07-30 21:34:41 -07:00
market_hours_range.go fixing market hours 2016-07-30 21:34:41 -07:00
math_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
math.go big api overhauls. 2016-07-29 18:24:25 -07:00
pie_chart_test.go need to flesh out this test more. 2016-07-28 14:30:00 -07:00
pie_chart.go tweaks. 2016-07-29 18:40:43 -07:00
range.go introduces the Range interface (instead of a concrete type). 2016-07-21 14:11:27 -07:00
raster_renderer.go pie charts! 2016-07-28 02:34:44 -07:00
README.md readme. 2016-07-30 09:39: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 pie charts! 2016-07-28 02:34:44 -07:00
ring_buffer_test.go moving averages! dashes! 2016-07-14 09:27:23 -07:00
ring_buffer.go tests. 2016-07-27 12:34:15 -07:00
roboto.go initial commit. 2016-07-06 18:54:00 -07:00
sequence_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
sequence.go big api overhauls. 2016-07-29 18:24:25 -07:00
series.go axis tick position 2016-07-30 09:12:03 -07:00
sma_series_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
sma_series.go axis tick position 2016-07-30 09:12:03 -07:00
stacked_bar_chart.go fixing fit issues on the xaxis labels for stacked bar. 2016-07-30 09:35:44 -07:00
style_test.go text options! 2016-07-29 16:36:29 -07:00
style.go tweaks. 2016-07-29 18:40:43 -07:00
text_test.go big api overhauls. 2016-07-29 18:24:25 -07:00
text.go where did my ticks go. 2016-07-29 19:35:18 -07:00
tick_test.go need to rewrite this test. 2016-07-30 12:59:59 -07:00
tick.go fixing sanity check test on gen ticks. 2016-07-30 20:30:19 -07:00
time_series_test.go updates 2016-07-09 20:14:11 -07:00
time_series.go axis tick position 2016-07-30 09:12:03 -07:00
value_formatter_provider.go mostly works. 2016-07-10 10:43:04 -07:00
value_formatter_test.go test fixes 2016-07-17 14:32:27 -07:00
value_formatter.go response times example needs some ergonomic love. 2016-07-17 14:25:42 -07:00
value_provider.go bad interface format 2016-07-18 15:44:22 -07:00
value_test.go test updates. 2016-07-28 18:56:45 -07:00
value.go big api overhauls. 2016-07-29 18:24:25 -07:00
vector_renderer_test.go text options! 2016-07-29 16:36:29 -07:00
vector_renderer.go big api overhauls. 2016-07-29 18:24:25 -07:00
xaxis_test.go fixing tests. 2016-07-30 20:20:59 -07:00
xaxis.go fixing market hours 2016-07-30 21:34:41 -07:00
yaxis_test.go fixing tests. 2016-07-30 20:20:59 -07:00
yaxis.go fixing things with generated ticks. 2016-07-30 12:57:18 -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:

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.