df

package
v0.0.0-...-3f99bb8 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPlotHeight = 480
View Source
const DefaultPlotRatio = 16.0 / 9.0
View Source
const DefaultPlotWidth = 0

Default height for gonum plot, in pixels

View Source
const Inch480px = 480 / 96
View Source
const Inch640px = 640 / 96

assuming 96 DPI

Variables

View Source
var (
	ExampleSVG         = &svg{}
	ExamplePNG         = &pngExample{}
	ExampleGonumPlot   = &gonumPlot{}
	ExampleEChartsPlot = &echartsPlot{}
)

Functions

func AsAny

func AsAny[T SupportedType](data []T) []any

func Avg

func Avg[T float64 | int](data []T) float64

func EChartRenderMode

func EChartRenderMode(mode RenderMode)

func Map

func Map[T, U any](s []T, f func(T) U) []U

Types

type ChartOption

type ChartOption func(*chartConfig)

func LineFn

func LineFn(name string, fn func(float64) float64) ChartOption

func LineXY

func LineXY(name string, x, y []float64) ChartOption

func Name

func Name(name string) ChartOption

func PlotX

func PlotX(x iter.Seq[float64]) ChartOption

func Ratio

func Ratio(ratio float64) ChartOption

func Size

func Size(width, height int) ChartOption

func XName

func XName(name string) ChartOption

func YName

func YName(name string) ChartOption

type DataFrame

type DataFrame interface {
	fmt.Stringer

	Columns() []string
	Rows() int

	GetColumn(name string) Series
	GetColumnAt(index int) Series
	SetColumn(data Series) error
	SetColumnAt(index int, data Series) error
	RemoveColumn(name string) error
	RemoveColumnAt(index int) error

	Head(n int) DataFrame
	Tail(n int) DataFrame
	Avg() DataFrame

	// Plot(options ...ChartOption)
	Bar(options ...ChartOption)
	Line(options ...ChartOption)
	Pie(options ...ChartOption)
	XY(options ...ChartOption)
}

DataFrame interface to define the operations on a DataFrame

func FromRandomValue

func FromRandomValue(rows, cols int, columns []string) DataFrame

FromRandomValue generates a DataFrame with random float64 values.

func FromRecords

func FromRecords(data [][]any, columns []string) DataFrame

FromRecords creates a DataFrame from a slice of slices where each inner slice represents a row

func NewDataFrame

func NewDataFrame(columns ...Series) DataFrame

NewDataFrame creates a new DataFrame with the given columns in the given order

type EChart

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

func NewEChart

func NewEChart(chart render.Renderer) *EChart

func (*EChart) HTML

func (c *EChart) HTML() string

func (*EChart) Options

func (c *EChart) Options() []term.BlockOption

type LineData

type LineData struct {
	Name string
	X    []float64
	Y    []float64
	Fn   func(float64) float64
}

type RenderMode

type RenderMode string
const (
	IFrameMode RenderMode = "iframe"
	DivMode    RenderMode = "div"
)

Default height for the echart iframe, in pixels. The chart only needs 530px, but the body has a padding of 8px.

type Series

type Series interface {
	fmt.Stringer

	Len() int
	Name() string
	Data() []any
	ToFloat64() []float64
	AsFloat64() []float64
	AsInt() []int
	AsString() []string
	Avg() Series
}

func NewRandomFloat64Series

func NewRandomFloat64Series(name string, len int, min float64, max float64) Series

func NewRandomIntSeries

func NewRandomIntSeries(name string, len, max int) Series

func NewSeries

func NewSeries[T SupportedType](name string, data []T) Series

func NewSeriesAny

func NewSeriesAny(name string, data []any) Series

func NewStringSeries

func NewStringSeries(name string, len int) Series

type SupportedType

type SupportedType interface {
	~string | ~float64 | ~int
}

SupportedType constrains the types that can be used in a Series

type XYChart

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

func NewGonumPlot

func NewGonumPlot(p *plot.Plot) *XYChart

func NewXY

func NewXY(name string, xx []float64, yy []float64, options ...ChartOption) (*XYChart, error)

func NewXYChart

func NewXYChart(options ...ChartOption) (*XYChart, error)

func NewXYFn

func NewXYFn(name string, fn func(float64) float64, options ...ChartOption) (*XYChart, error)

func (*XYChart) HTML

func (c *XYChart) HTML() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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