Provide basic charts in go

Overview

Charts for Go

Basic charts in go.

This package focuses more on autoscaling, error bars, and logarithmic plots than on beautifull or marketing ready charts.

Examples

Some nice charts

Chart Types

The following chart types are implemented:

  • Strip Charts
  • Scatter / Function-Plot Charts
  • Histograms
  • Bar and Categorical Bar Charts
  • Pie/Ring Charts
  • Boxplots

Some Features

  • Axis can be linear, logarithmical, categorical or time/date axis.
  • Autoscaling with lots of options
  • Fine control of tics and labels

Output / Graphic Formats

Package chart itself provideds the charts/plots itself, the charts/plots can be output to different graphic drivers. Currently

  • txtg: ASCII art charts
  • svgg: scalable vector graphics (via github.com/ajstarks/svgo), and
  • imgg: Go image.RGBA (via code.google.com/p/draw2d/draw2d/ and code.google.com/p/freetype-go) are implemented.

For a quick overview save as xbestof.{png,svg,txt} run

  $ example/example -best

A fuller overview can be generated by

  $ example/example -All

Quirks

  • Style handling (especialy colour) is a bit of a mess .
  • Text based charts are cute. But the general graphics would be much easier without.
  • Time handling code dates back to pre Go1, it should be reworked.
Comments
  • Update draw2d repo

    Update draw2d repo

    The old code.google.com repo will be deleted. The github draw2d repo has now also a new pdf backend. You can use this to generate with the same draw2d code pdf charts.

    For a demo pdf output see:

    • https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/geometry.pdf
    • https://raw.githubusercontent.com/llgcode/draw2d/master/resource/image/postscript.pdf
    opened by stanim 5
  • Set a seed for the example plots

    Set a seed for the example plots

    At the moment if you tried to diff images to see if you changed anything, you get a different image anyway due to the use of the rand package.

    TIL: github has a nice visual diff

    opened by pwaller 3
  • Add experimental and incomplete opengl backend

    Add experimental and incomplete opengl backend

    You can leave this pull request outstanding until I implement drawing "best of", if you like.

    This is the last request of the day. Thanks for chart, it is really useful!

    opened by pwaller 3
  • fixing issue 27: now SVG graphics are correct for PieCharts >180°

    fixing issue 27: now SVG graphics are correct for PieCharts >180°

    fixes https://github.com/vdobler/chart/issues/27

    In the code there is now a comparison which sets the "large-arc-flag" if needed as described in the SVG documenation.

    Examples of plots:

    Schnappschuss (2019-07-24 18 18 33) Schnappschuss (2019-07-24 18 18 13)
    opened by harenber 2
  • T location added

    T location added

    Hi,

    This is just a suggestion but I recommend adding a way people can overwrite the timezone location for the TRange stuff. This is just an "example" of how I hacked it together to work for me, unfortunately I don't have a good understanding on how this library is working so it might not be the best solution.

    Regards, Arran

    opened by arranubels 2
  • Incorrect bitshifts

    Incorrect bitshifts

    github.com/vdobler/chart/svgg/svg.go:59: suspicious shift of sg.bg.R
    github.com/vdobler/chart/svgg/svg.go:59: suspicious shift of sg.bg.G
    github.com/vdobler/chart/svgg/svg.go:59: suspicious shift of sg.bg.B
    github.com/vdobler/chart/svgg/svg.go:60: suspicious shift of sg.bg.A
    github.com/vdobler/chart/svgg/svg.go:73: suspicious shift of sg.bg.R
    github.com/vdobler/chart/svgg/svg.go:73: suspicious shift of sg.bg.G
    github.com/vdobler/chart/svgg/svg.go:73: suspicious shift of sg.bg.B
    github.com/vdobler/chart/svgg/svg.go:73: suspicious shift of sg.bg.A
    

    The above locations shift color.RGBA fields right by 8 (c.R >> 8). But as they are uint8s, a right shift of 8 will always yield 0. It's not obvious what these shifts are supposed to be doing.

    opened by mjibson 2
  • feature request: draw lines using a continuous polygon

    feature request: draw lines using a continuous polygon

    I'm working on an OpenGL backend for chart, and it's really obvious that some lines are composed out of lots of little lines.

    Would it be possible to make a new Polygon function? Backends not implementing it yet could fall back to drawing individual lines.

    opened by pwaller 2
  • go get currently broken on go1.0.2

    go get currently broken on go1.0.2

    If I try to install the example, I get the following error:

    $ go get -v github.com/vdobler/chart/example
    github.com/vdobler/chart/imgg
    # github.com/vdobler/chart/imgg
    github.com/vdobler/chart/imgg/image.go:101: cannot use dpi (type int) as type float64 in function argument
    github.com/vdobler/chart/imgg/image.go:110: c.FUnitToFix32 undefined (type *freetype.Context has no field or method FUnitToFix32)
    github.com/vdobler/chart/imgg/image.go:110: cannot use prev (type truetype.Index) as type int32 in function argument
    github.com/vdobler/chart/imgg/image.go:110: not enough arguments in call to ig.font.Kerning
    github.com/vdobler/chart/imgg/image.go:112: c.FUnitToFix32 undefined (type *freetype.Context has no field or method FUnitToFix32)
    github.com/vdobler/chart/imgg/image.go:112: cannot use index (type truetype.Index) as type int32 in function argument
    github.com/vdobler/chart/imgg/image.go:112: not enough arguments in call to ig.font.HMetric
    github.com/vdobler/chart/imgg/image.go:259: cannot use dpi (type int) as type float64 in function argument
    github.com/vdobler/chart/imgg/image.go:267: c.FUnitToPixelRU undefined (type *freetype.Context has no field or method FUnitToPixelRU)
    github.com/vdobler/chart/imgg/image.go:267: ig.font.UnitsPerEm undefined (type *truetype.Font has no field or method UnitsPerEm)
    github.com/vdobler/chart/imgg/image.go:267: too many errors
    
    opened by pwaller 2
  • Fixing #27: properly paint SVG arcs with angles >180°

    Fixing #27: properly paint SVG arcs with angles >180°

    fixes https://github.com/vdobler/chart/issues/27

    In the code there is now a comparison which sets the "large-arc-flag" if needed as described in the SVG documenation.

    Examples of plots:

    Schnappschuss (2019-07-24 18 18 33) Schnappschuss (2019-07-24 18 18 13)
    opened by harenber 1
  • Wrongly and inconsistently labeled points

    Wrongly and inconsistently labeled points

    package main
    
    import (
    	"image/color"
    	"image/jpeg"
    	"log"
    	"os"
    
    	"github.com/vdobler/chart"
    	"github.com/vdobler/chart/imgg"
    )
    
    func main() {
    	style := chart.Style{Symbol: 'o', LineColor: color.NRGBA{0x00, 0x00, 0xff, 0xff},
    		FillColor: color.NRGBA{0xff, 0xff, 0xff, 0xff},
    		LineStyle: chart.SolidLine, LineWidth: 2}
    	c := chart.BarChart{}
    	c.YRange.Label = "Total"
    	c.YRange.Fixed(0, 56000, 5000)
    	c.AddDataPair("Total",
    		[]float64{1, 2, 3, 4, 5},
    		[]float64{55954, 55653, 54100, 51527, 44034}, style)
    	g := imgg.New(640, 480, color.RGBA{255, 255, 255, 255}, nil, nil)
    	c.Plot(g)
    	fo, err := os.Create("output.jpg")
    	if err != nil {
    		log.Fatal(err)
    	}
    	defer fo.Close()
    	if err = jpeg.Encode(fo, g.Image, nil); err != nil {
    		log.Fatal(err)
    	}
    }
    

    Result: https://i.imgur.com/5dLCgVp.jpg

    Y axis: 5000 is formatted as 5.0 k unlike all the other values (10 k, not 10.0 k, etc.)

    X axis: the first label is somehow 500m (?) instead of 0 or 0.0.

    opened by opennota 1
  • Documentation issue [	absence of examples]

    Documentation issue [ absence of examples]

    I am newbie to go and can't understand how to use this package. Can you please provide basic usage with some examples. Because example you provided is big and hard to understand for me :(. And when I start my own test project I have errors like this:

    ../../.go/src/github.com/vdobler/chart/imgg/image.go:9:2: cannot find package "github.com/golang/freetype" in any of:
        /usr/lib/go/src/github.com/golang/freetype (from $GOROOT)
        /home/kir/.go/src/github.com/golang/freetype (from $GOPATH)
    ../../.go/src/github.com/vdobler/chart/imgg/image.go:10:2: cannot find package "github.com/golang/freetype/truetype" in any of:
        /usr/lib/go/src/github.com/golang/freetype/truetype (from $GOROOT)
        /home/kir/.go/src/github.com/golang/freetype/truetype (from $GOPATH)
    ../../.go/src/github.com/vdobler/chart/imgg/image.go:11:2: cannot find package "github.com/llgcode/draw2d" in any of:
        /usr/lib/go/src/github.com/llgcode/draw2d (from $GOROOT)
        /home/kir/.go/src/github.com/llgcode/draw2d (from $GOPATH)
    ../../.go/src/github.com/vdobler/chart/imgg/image.go:12:2: cannot find package "github.com/llgcode/draw2d/draw2dimg" in any of:
        /usr/lib/go/src/github.com/llgcode/draw2d/draw2dimg (from $GOROOT)
        /home/kir/.go/src/github.com/llgcode/draw2d/draw2dimg (from $GOPATH)
    ../../.go/src/github.com/vdobler/chart/imgg/image.go:14:2: cannot find package "golang.org/x/image/draw" in any of:
        /usr/lib/go/src/golang.org/x/image/draw (from $GOROOT)
        /home/kir/.go/src/golang.org/x/image/draw (from $GOPATH)
    ....
    
    opened by luminousmen 1
  • Fix function comments based on best practices from Effective Go

    Fix function comments based on best practices from Effective Go

    Every exported function in a program should have a doc comment. The first sentence should be a summary that starts with the name being declared. From effective go.

    I generated this with CodeLingo and I'm keen to get some feedback, but this is automated so feel free to close it and just say "opt out" to opt out of future CodeLingo outreach PRs.

    opened by Daanikus 3
  • out of memory error when logarithmic Y-Axis scale includes the range from 7e-11 to 9.999e-11

    out of memory error when logarithmic Y-Axis scale includes the range from 7e-11 to 9.999e-11

    I'm getting an "out of memory" error when trying to plot data on a logarithmic scale, but only when the data is within a certain range. Please look at the following:

    https://jsfiddle.net/vp72e7j9/

    If the data is above or below the range, the chart renders fine, however, if the data enters this range, the memory spikes and you get the error. (Watch the browser memory in Task Manager to see it spike). I'm using Firefox but it crashes in Chrome as well.

    opened by jvolf-zolo 0
  • BarChart wrong formatted bars

    BarChart wrong formatted bars

    The following snippet will generate the attached wrong formatted bar chart. If more bars are used the formatting looks okay, so somehow the bar width and pos calculation for one or two datapoints is wrong. chart_issue

    func IssueChart() error {
        wuc := chart.BarChart{Title: "Weekly Data Usage"}
        wuc.XRange.Category = []string{"W1", "W2"}
        wuc.XRange.Label, wuc.YRange.Label = "Calendar Week", "Data Transfer (MB)"
        wuc.Key.Pos, wuc.Key.Cols, wuc.Key.Border = "otc", 2, -1
        wuc.YRange.ShowZero = true
        wuc.ShowVal = 0
        pos := []float64{0, 1}
        rx := []float64{100.0, 150.0}
        tx := []float64{50.0, 200.0}
        wuc.AddDataPair("RX (Download)", pos, rx,
            chart.Style{Symbol: 'o', LineColor: color.NRGBA{69, 117, 179, 0xff}, LineWidth: 2, FillColor: color.NRGBA{79, 127, 189, 0xff}})
        wuc.AddDataPair("TX (Upload)", pos, tx,
            chart.Style{Symbol: 'o', LineColor: color.NRGBA{182, 70, 67, 0xff}, LineWidth: 2, FillColor: color.NRGBA{192, 80, 77, 0xff}})
        // Save image
        igr := imgg.New(1024, 640, color.RGBA{0xff, 0xff, 0xff, 0xff}, nil, nil)
        wuc.Plot(igr)
        fh, err := os.Create("chart_issue.jpg")
        if err != nil {
            return err
        }
        err = jpeg.Encode(fh, igr.Image, nil)
        return err
    }
    
    opened by nekrondev 1
  • runtime: out of memory when drawing logarithmic y axis

    runtime: out of memory when drawing logarithmic y axis

    Hello, I try to plot a bar chart with a logarithmic y axis, but I always get an out of memory exception in: chart.go:569 I tried hiding the tics, limiting the max range and setting delta to a tenth of my maximum value, but it's not helping. Do you have an idea how I can circumvent this? Interestingly, the example logarithmic chart works. I would be glad to provide further information if you require.

    Greetings, Alex

    opened by AlKoFDC 3
Owner
Volker Dobler
Volker Dobler
Maybe is a Go package to provide basic functionality for Option type structures

Maybe Maybe is a library that adds an Option data type for some native Go types. What does it offer: The types exported by this library are immutable

Pablo Morelli 9 Oct 4, 2022
This repository holds additional AzBlob TransferManager(s) that provide more robust options than the basic managers that are either a sync

Please ⭐ this project Introduction This repository holds additional AzBlob TransferManager(s) that provide more robust options than the basic managers

John Doak 2 May 26, 2022
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.

?? PTerm | Pretty Terminal Printer A golang module to print pretty text Show Demo Code PTerm.sh | Installation | Documentation | Quick Start | Example

null 3.1k Dec 5, 2022
🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

go-echarts 5k Dec 8, 2022
Very simple charts with some debug data for Go programs

debugcharts Go memory debug charts. This package uses Plotly chart library. It is open source and free for use. Installation go get -v -u github.com/m

Marko Kevac 481 Nov 23, 2022
Create changelogs for Helm Charts, based on git history

helm-changelog Create changelogs for Helm Charts, based on git history. The application depends on the assumption that the helm chart is released on t

Frederik Mogensen 37 Nov 27, 2022
Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider.

dredger Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider. Dredger is made of dark magic and cannot full

Synchronoss 14 Aug 25, 2022
go-echarts 🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

go-echarts 5k Dec 2, 2022
View historical Docker Hub image pull charts for all public Docker Images.

dockerstats.com ⚠️ Due to recent changes to Docker Hub APIs (rate limits) and new business model, dockerstats.com can no longer collect image statisti

hackerman 45 May 19, 2022
Helm Operator is designed to managed the full lifecycle of Helm charts with Kubernetes CRD resource.

Helm Operator Helm Operator is designed to install and manage Helm charts with Kubernetes CRD resource. Helm Operator does not create the Helm release

Chen Zhiwei 5 Aug 25, 2022
Helm plugin to reference value files packaged in dependency charts

Helm Octopus Plugin This Helm plugin allows to reference packaged value files (other than the default values.yaml). Install helm plugin install https:

Softonic 3 Sep 23, 2021
SSR charts as a Component

kyoto charts SSR Charts as a Component. Prototyped for using in kyoto pages. Kyoto charts are using go-chart under the hood to generate charts on serv

Yurii Zinets 3 Jun 3, 2022
Helm : a tool for managing Charts

Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources.

邓杰 0 Aug 25, 2022
Helm : a tool for managing Kubernetes charts

Helm Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources. Use Helm to: Find and use popular soft

null 0 Nov 30, 2021
A charts library for Golang

go-charts go-charts基于go-chart生成数据图表,无其它模块的依赖纯golang的实现,支持svg与png的输出,Apache ECharts在前端开发中得到众多开发者的认可,go-charts兼容Apache ECharts的配置参数,简单快捷的生成相似的图表(svg或png

Tree Xie 98 Dec 7, 2022
Amplitude-exporter - Amplitude charts to prometheus exporter PoC

Amplitude exporter Amplitude charts to prometheus exporter PoC. Work in progress

Andrey S. Kolesnichenko 1 May 26, 2022
Termbar - Generate terminal charts in Go

termbar Generate terminal bar charts in Go. a: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50 b: ▇

MergeStat 14 Mar 2, 2022
Basic-api-with-go - A basic api with golang

I am creating my first API with GO. Install go get -u github.com/Yefhem/basic-ap

Yefhem 1 Jan 3, 2022
Go-basic-graphql - Basic implementation of GraphQL using Go

Go-basic-graphql - Basic implementation of GraphQL using Go

Luis Felipe Ribeiro 0 Jan 29, 2022
🔥 Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

?? Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

Junaid Javed 19 Oct 4, 2022