go chart is a basic charting library in go.
Find a file
Zeni Kim cc8d36edd9
Some checks failed
Continuous Integration / Tests (push) Has been cancelled
update url
2024-10-27 21:52:38 -05:00
.github/workflows updates to ci, fixing busts in examples 2023-09-11 16:10:03 -04:00
_colors getting ready to add extended colors but stopping at basic colors for now 2023-11-04 13:30:06 -07:00
_images can rotate text + add y axis names 2016-08-06 21:59:46 -07:00
cmd/chart update url 2024-10-27 21:52:38 -05:00
drawing update url 2024-10-27 21:52:38 -05:00
examples update url 2024-10-27 21:52:38 -05:00
matrix update url 2024-10-27 21:52:38 -05:00
roboto Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
testutil getting ready to add extended colors but stopping at basic colors for now 2023-11-04 13:30:06 -07:00
.gitignore add logarithmic axes support, with tests. Supports positive Y-values only. (#141) 2023-05-22 08:37:57 -07:00
annotation_series.go mostly working 2019-02-13 18:55:13 -08:00
annotation_series_test.go update url 2024-10-27 21:52:38 -05:00
array.go mostly working 2019-02-13 18:55:13 -08:00
axis.go can just supply inverted ranges. 2017-01-09 17:57:45 -08:00
bar_chart.go fix(bar_charts): use YAxis.Render (#209) 2023-06-12 16:04:52 +02:00
bar_chart_test.go update url 2024-10-27 21:52:38 -05:00
bollinger_band_series.go mostly working 2019-02-13 18:55:13 -08:00
bollinger_band_series_test.go update url 2024-10-27 21:52:38 -05:00
bounded_last_values_annotation_series.go additions 2019-09-09 20:21:51 -07:00
box.go narrow fix for CVE-2024-40060 2024-08-23 08:41:44 -07:00
box_test.go update url 2024-10-27 21:52:38 -05:00
chart.go tests pass 2019-02-16 11:17:39 -08:00
chart_test.go update url 2024-10-27 21:52:38 -05:00
colors.go update url 2024-10-27 21:52:38 -05:00
concat_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
concat_series_test.go update url 2024-10-27 21:52:38 -05:00
continuous_range.go mostly working 2019-02-13 18:55:13 -08:00
continuous_range_test.go update url 2024-10-27 21:52:38 -05:00
continuous_series.go mostly working 2019-02-13 18:55:13 -08:00
continuous_series_test.go update url 2024-10-27 21:52:38 -05:00
COVERAGE switching to generators 2019-09-09 21:02:48 -07:00
defaults.go color maps 2017-04-14 17:43:52 -07:00
donut_chart.go merging master 2019-09-09 20:24:15 -07:00
donut_chart_test.go update url 2024-10-27 21:52:38 -05:00
draw.go Add stacked bar chart value labels (#60) and a horizontal stacked bar chart (#39) (#114) 2019-12-06 11:22:51 -08:00
ema_series.go updates + tests 2018-09-07 12:52:30 -07:00
ema_series_test.go update url 2024-10-27 21:52:38 -05:00
fileutil.go removing go-sdk stuff 2019-04-24 12:58:05 -07:00
first_value_annotation.go updates + tests 2018-09-07 12:52:30 -07:00
first_value_annotation_test.go update url 2024-10-27 21:52:38 -05:00
font.go update url 2024-10-27 21:52:38 -05:00
go.mod Bump golang.org/x/image from 0.12.0 to 0.18.0 (#225) 2024-06-26 12:37:07 -07:00
go.sum Bump golang.org/x/image from 0.12.0 to 0.18.0 (#225) 2024-06-26 12:37:07 -07:00
grid_line.go changing gridline behavior. 2016-08-11 20:42:25 -07:00
grid_line_test.go update url 2024-10-27 21:52:38 -05:00
histogram_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
histogram_series_test.go update url 2024-10-27 21:52:38 -05:00
image_writer.go adding validation. 2017-02-03 11:26:53 -08:00
jet.go update url 2024-10-27 21:52:38 -05:00
last_value_annotation_series.go updates 2019-02-13 19:13:29 -08:00
last_value_annotation_series_test.go update url 2024-10-27 21:52:38 -05:00
legend.go update url 2024-10-27 21:52:38 -05:00
legend_test.go update url 2024-10-27 21:52:38 -05:00
LICENSE update url 2024-10-27 21:52:38 -05:00
linear_coefficient_provider.go sequence tweaks, removing market hours anything 2018-09-10 13:08:20 -07:00
linear_regression_series.go snapshot 2019-02-13 16:09:26 -08:00
linear_regression_series_test.go update url 2024-10-27 21:52:38 -05:00
linear_sequence.go mostly working 2019-02-13 18:55:13 -08:00
linear_series.go sequence tweaks, removing market hours anything 2018-09-10 13:08:20 -07:00
logarithmic_range.go add logarithmic axes support, with tests. Supports positive Y-values only. (#141) 2023-05-22 08:37:57 -07:00
logarithmic_range_test.go update url 2024-10-27 21:52:38 -05:00
logger.go adds percent change series 2019-09-09 19:57:56 -07:00
macd_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
macd_series_test.go update url 2024-10-27 21:52:38 -05:00
Makefile Adds support for go mod (finally) (#164) 2020-11-22 16:45:10 -08:00
mathutil.go snapshot 2019-02-13 16:09:26 -08:00
min_max_series.go Helper API refactor (#40) 2017-05-12 17:12:23 -07:00
parse.go removing go-sdk stuff 2019-04-24 12:58:05 -07:00
percent_change_series.go adds percent change series 2019-09-09 19:57:56 -07:00
percent_change_series_test.go update url 2024-10-27 21:52:38 -05:00
pie_chart.go mostly working 2019-02-13 18:55:13 -08:00
pie_chart_test.go update url 2024-10-27 21:52:38 -05:00
polynomial_regression_series.go update url 2024-10-27 21:52:38 -05:00
polynomial_regression_test.go update url 2024-10-27 21:52:38 -05:00
PROFANITY_RULES.yml removing go-sdk completely 2019-04-24 13:00:09 -07:00
random_sequence.go mostly working 2019-02-13 18:55:13 -08:00
range.go descending 2017-01-10 13:50:17 -08:00
raster_renderer.go update url 2024-10-27 21:52:38 -05:00
README.md Start copy from https://github.com/wcharczuk/go-chart 2024-10-27 16:38:55 -05:00
renderable.go api tweaks. 2016-07-14 18:29:06 -07:00
renderer.go update url 2024-10-27 21:52:38 -05:00
renderer_provider.go snapshot. 2016-07-10 01:11:47 -07:00
seq.go updates 2019-02-13 19:13:29 -08:00
seq_test.go update url 2024-10-27 21:52:38 -05:00
series.go adding validation. 2017-02-03 11:26:53 -08:00
sma_series.go snapshot 2019-02-13 16:09:26 -08:00
sma_series_test.go update url 2024-10-27 21:52:38 -05:00
stacked_bar_chart.go narrow fix for CVE-2024-40060 2024-08-23 08:41:44 -07:00
stringutil.go snapshot 2019-02-13 16:09:26 -08:00
stringutil_test.go update url 2024-10-27 21:52:38 -05:00
style.go update url 2024-10-27 21:52:38 -05:00
style_test.go update url 2024-10-27 21:52:38 -05:00
text.go Add stacked bar chart value labels (#60) and a horizontal stacked bar chart (#39) (#114) 2019-12-06 11:22:51 -08:00
text_test.go update url 2024-10-27 21:52:38 -05:00
tick.go snapshot 2019-02-13 16:09:26 -08:00
tick_test.go update url 2024-10-27 21:52:38 -05:00
time_series.go snapshot 2019-02-13 16:09:26 -08:00
time_series_test.go update url 2024-10-27 21:52:38 -05:00
times.go removing go-sdk completely 2019-04-24 13:00:09 -07:00
timeutil.go mostly working 2019-02-13 18:55:13 -08:00
value.go snapshot 2019-02-13 16:09:26 -08:00
value_buffer.go mostly working 2019-02-13 18:55:13 -08:00
value_buffer_test.go update url 2024-10-27 21:52:38 -05:00
value_formatter.go add logarithmic axes support, with tests. Supports positive Y-values only. (#141) 2023-05-22 08:37:57 -07:00
value_formatter_provider.go mostly works. 2016-07-10 10:43:04 -07:00
value_formatter_test.go update url 2024-10-27 21:52:38 -05:00
value_provider.go update url 2024-10-27 21:52:38 -05:00
value_test.go update url 2024-10-27 21:52:38 -05:00
vector_renderer.go update url 2024-10-27 21:52:38 -05:00
vector_renderer_test.go update url 2024-10-27 21:52:38 -05:00
viridis.go update url 2024-10-27 21:52:38 -05:00
xaxis.go tests pass 2019-02-16 11:17:39 -08:00
xaxis_test.go update url 2024-10-27 21:52:38 -05:00
yaxis.go tests pass 2019-02-16 11:17:39 -08:00
yaxis_test.go update url 2024-10-27 21:52:38 -05:00

go-chart

This project starts from a full copy from https://github.com/wcharczuk/go-chart. 28 Oct 2024.

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 github.com/wcharczuk/go-chart/v2@latest

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/v2" //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.