data

package
v0.0.0-...-fd21f57 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 1 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection []Data

Collection defines an array of datasets.

func (Collection) Len

func (c Collection) Len() int

func (Collection) Less

func (c Collection) Less(i, j int) bool

func (Collection) Normalize

func (c Collection) Normalize(limit int)

Normalize normalizes all values.

func (Collection) Swap

func (c Collection) Swap(i, j int)

type Data

type Data struct {
	Max    float64  `json:"fmax"`   // max raw value
	NMax   int      `json:"max"`    // max normalized value
	Scale  []string `json:"scale"`  // yaxis labels
	Values []int    `json:"values"` // pixel values
	Type   string   `json:"type"`
	Title  string   `json:"title"`
	// contains filtered or unexported fields
}

Data contains a single set of data most likely imported from tsm.

func NewData

func NewData(opt *Options, in []float64) Data

NewData creates a new dataset from []float64.

func (*Data) Len

func (d *Data) Len() int

Len returns the number of items in the dataset.

func (*Data) MinMaxAvg

func (d *Data) MinMaxAvg() (float64, float64, float64)

MinMaxAvg returns the Minimum, Maximum and Average values of the raw data.

func (*Data) Resample

func (d *Data) Resample(width int)

Resample resamples the raw data. It either streches the data to fit the witdth or it uses the Largest Triangle Three Bucket algorithm to fit the data to the new width.

type Options

type Options struct {
	// Type specified the chart type to plot. Can be either "area" of "line".
	// By default "area" is used. XXX Note that line isn't really supported.
	Type string

	// Title to display on top of the chart.
	Title string

	// Gap is the % of space between bar charts, of the number of datapoints
	// supplied is smaller than the chart width. I.e. plotting 30 values with
	// a chart width of 300 and a Gap of 0.1 plots 30 individual bar chart
	// value with a thickness of 24px with 2 * 10% (left & right) space in between.
	// By default the Gap is 0.00.
	Gap float64
}

Options contains configuration for a single dataset.

Jump to

Keyboard shortcuts

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