Debian Codegraph @

/

debian golang-github-wcharczuk-go-chart 2.1.2-1debian golang-github-wcharczuk-go-chart-dev debiangomakemakefilemarkdownshellxmlyaml 181 files · 48 symbols
View dependency graph

Depends on

README (full)

go-chart

Continuous Integration Go Report Card

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

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.

dir .github/
dir _colors/
dir _images/
dir cmd/
dir debian/
dir drawing/
dir examples/
dir matrix/
dir roboto/
dir testutil/
file .gitignore
file COVERAGE
file LICENSE
file Makefile
file PROFANITY_RULES.yml
file README.md
file annotation_series.go
file annotation_series_test.go
file array.go
file axis.go
file bar_chart.go
file bar_chart_test.go
file bollinger_band_series.go
file bollinger_band_series_test.go
file bounded_last_values_annotation_series.go
file box.go
file box_test.go
file chart.go
file chart_test.go
file colors.go
file concat_series.go
file concat_series_test.go
file continuous_range.go
file continuous_range_test.go
file continuous_series.go
file continuous_series_test.go
file defaults.go
file donut_chart.go
file donut_chart_test.go
file draw.go
file ema_series.go
file ema_series_test.go
file fileutil.go
file first_value_annotation.go
file first_value_annotation_test.go
file font.go
file go.mod
file go.sum
file grid_line.go
file grid_line_test.go
file histogram_series.go
file histogram_series_test.go
file image_writer.go
file jet.go
file last_value_annotation_series.go
file last_value_annotation_series_test.go
file legend.go
file legend_test.go
file linear_coefficient_provider.go
file linear_regression_series.go
file linear_regression_series_test.go
file linear_sequence.go
file linear_series.go
file logarithmic_range.go
file logarithmic_range_test.go
file logger.go
file macd_series.go
file macd_series_test.go
file mathutil.go
file min_max_series.go
file parse.go
file percent_change_series.go
file percent_change_series_test.go
file pie_chart.go
file pie_chart_test.go
file polynomial_regression_series.go
file polynomial_regression_test.go
file random_sequence.go
file range.go
file raster_renderer.go
file renderable.go
file renderer.go
file renderer_provider.go
file seq.go
file seq_test.go
file series.go
file sma_series.go
file sma_series_test.go
file stacked_bar_chart.go
file stringutil.go
file stringutil_test.go
file style.go
file style_test.go
file text.go
file text_test.go
file tick.go
file tick_test.go
file time_series.go
file time_series_test.go
file times.go
file timeutil.go
file value.go
file value_buffer.go
file value_buffer_test.go
file value_formatter.go
file value_formatter_provider.go
file value_formatter_test.go
file value_provider.go
file value_test.go
file vector_renderer.go
file vector_renderer_test.go
file viridis.go
file xaxis.go
file xaxis_test.go
file yaxis.go
file yaxis_test.go