timelapsechart

package module
v0.0.0-...-53da189 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

timelapsechart-go

Go library to generate a time-lapse bar chart in SVG format.

timelapsechart-go output

usage

package main

import (
    "bytes"
    "fmt"
    "log"

    "github.com/jimareed/timelapsechart-go"
)

func main() {

    csv, err := os.Open("input.csv")
    if err != nil {
        log.Fatalln(err)
    }
    defer csv.Close()

    data := timelapsechart.Data{}
    err = data.ReadCSV(csv, []string{"country", "date", "total"})
    if err != nil {
        log.Fatalln("Couldn't open the csv file", err)
    }

    chart := timelapsechart.New("Covid Cases", "bar", timelapsechart.Config{})
    chart.AddData(&data)

    buffer := bytes.NewBuffer([]byte{})
    chart.Render(buffer)
    fmt.Println(buffer)
}

Sources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BarChart

type BarChart struct {
	// contains filtered or unexported fields
}

BarChart

type Chart

type Chart struct {
	Config Config   `json:"config"`
	Title  string   `json:"title"`
	Data   *Data    `json:"data"`
	Type   string   `json:"type"`
	Labels []string `json:"labels"`
}

Chart

func New

func New(title string, chartType string, config Config) *Chart

func (*Chart) AddData

func (chart *Chart) AddData(data *Data) error

func (*Chart) AddLabels

func (chart *Chart) AddLabels(labels []string)

func (*Chart) GetColor

func (chart *Chart) GetColor(index int) string

func (*Chart) RectWidth

func (chart *Chart) RectWidth(value float64) float64

func (*Chart) Render

func (chart *Chart) Render(buffer *bytes.Buffer) error

func (*Chart) Table

func (chart *Chart) Table()

type Config

type Config struct {
	Width     int      `json:"width"`
	Height    int      `json:"height"`
	LabelSize int      `json:"labelSize"`
	ChartX    int      `json:"chartX"`
	ChartY    int      `json:"chartY"`
	Palette   []string `json:"palette"`
}

Config

type Data

type Data struct {
	Categories     []string `json:"categories"`
	TimeRange      []string `json:"timeRange"`
	MaxValue       float64  `json:"maxValue"`
	CategoryColumn string   `json:"categoryColumn"`
	TimeColumn     string   `json:"timeColumn"`
	ValueColumn    string   `json:"valueColumn"`
	Value2Column   string   `json:"value2Column"`
	// contains filtered or unexported fields
}

Data

func (*Data) AddCategory

func (data *Data) AddCategory(newCategory string) error

func (*Data) GetMaxValue

func (data *Data) GetMaxValue() float64

func (*Data) GetValue

func (data *Data) GetValue(category int, index int) float64

func (*Data) GetValue2

func (data *Data) GetValue2(category int, index int) float64

func (*Data) ReadCSV

func (data *Data) ReadCSV(r io.ReadSeeker, cols []string) error

type GanttChart

type GanttChart struct {
	// contains filtered or unexported fields
}

GanttChart

func (*GanttChart) RectWidth

func (ganttChart *GanttChart) RectWidth(chart *Chart, value float64) float64

Directories

Path Synopsis
examples
example1 command
example2 command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址