statictimeseries

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

statictimeseriesdata provides tools for adding and formatting static time series data for reporting purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataSeriesItemTimes

func DataSeriesItemTimes(series *DataSeries) []time.Time

func DataSeriesMapMinMaxTimes

func DataSeriesMapMinMaxTimes(dsm map[string]DataSeries) (time.Time, time.Time, error)

func DataSeriesMapMinMaxValues

func DataSeriesMapMinMaxValues(dsm map[string]DataSeries) (int64, int64, error)

func DataSeriesMinMaxTimes

func DataSeriesMinMaxTimes(series *DataSeries) (time.Time, time.Time)

func DataSeriesSliceNames

func DataSeriesSliceNames(dsSlice []DataSeries) []string

func DataSeriesSliceTable

func DataSeriesSliceTable(dsSlice []DataSeries) table.Table

func DataSeriesSliceTimes

func DataSeriesSliceTimes(dsSlice []DataSeries) []string

func DataSeriesSliceWriteXLSX

func DataSeriesSliceWriteXLSX(filename string, dsSlice []DataSeries) error

DataSeriesSliceWriteXLSX writes a slice of DataSeries to an Excel XLSX file for easy consumption.

func DataSeriesTimeSeries

func DataSeriesTimeSeries(series *DataSeries, interval timeutil.Interval) []time.Time

func DataSeriesToTable

func DataSeriesToTable(ds DataSeries, col2 string, dtFmt func(dt time.Time) string) table.Table

DataSeriesToTable generates a `table.Table` given a `DataSeries`.

func DataSeriesWriteXLSX

func DataSeriesWriteXLSX(filename string, ds DataSeries, col2 string, dtFmt func(dt time.Time) string) error

DataSeriesWriteXLSX writes an XSLX file given a `DataSeries`

func MSS2MS

func MSS2MS(in map[string]map[string]int) map[string]int

func ReportAxisX

func ReportAxisX(dss DataSeriesSet, cols int, conv func(time.Time) string) []string

ReportAxisX generates data for use with `C3Chart.C3Axis.C3AxisX.Categories`.

func TimeFormatNiceMonth

func TimeFormatNiceMonth(dt time.Time) string

func TimeFormatNiceQuarter

func TimeFormatNiceQuarter(dt time.Time) string

func TimeFormatRFC3339

func TimeFormatRFC3339(dt time.Time) string

Types

type DataItem

type DataItem struct {
	SeriesName    string
	SeriesSetName string
	Time          time.Time
	IsFloat       bool
	Value         int64
	ValueFloat    float64
}

func ParseRecordsDataItems added in v1.3.0

func ParseRecordsDataItems(records [][]string, cfg TableConfig) ([]DataItem, error)

func (*DataItem) ValueFloat64

func (item *DataItem) ValueFloat64() float64

func (*DataItem) ValueInt64

func (item *DataItem) ValueInt64() int64

type DataSeries

type DataSeries struct {
	SeriesName string
	ItemMap    map[string]DataItem
	IsFloat    bool
	Interval   timeutil.Interval // Informational
}

func AggregateSeries

func AggregateSeries(s1 DataSeries) DataSeries

func DataSeriesDivide

func DataSeriesDivide(numer, denom DataSeries) (DataSeries, error)

func NewDataSeries

func NewDataSeries() DataSeries

func (*DataSeries) AddItem

func (ds *DataSeries) AddItem(item DataItem)

AddItem adds data item. It will sum values when existing time unit is encountered.

func (*DataSeries) DeleteByTime

func (ds *DataSeries) DeleteByTime(dt time.Time)

func (*DataSeries) GetTimeSlice

func (ds *DataSeries) GetTimeSlice(sortSlice bool) timeutil.TimeSlice

func (*DataSeries) ItemsSorted

func (ds *DataSeries) ItemsSorted() []DataItem

ItemsSorted returns sorted DataItems. This currently uses a simple string sort on RFC3339 times.

func (*DataSeries) Keys

func (ds *DataSeries) Keys() []string

Keys returns a sorted listed of Item keys.

func (*DataSeries) Last

func (ds *DataSeries) Last() (DataItem, error)

func (*DataSeries) LastItem

func (ds *DataSeries) LastItem(skipIfTimePartialValueLessPrev bool) (DataItem, error)

func (*DataSeries) MaxValue

func (ds *DataSeries) MaxValue() int64

func (*DataSeries) MinMaxTimes

func (series *DataSeries) MinMaxTimes() (time.Time, time.Time)

func (*DataSeries) MinMaxValues

func (ds *DataSeries) MinMaxValues() (int64, int64)

func (*DataSeries) MinMaxValuesFloat64

func (ds *DataSeries) MinMaxValuesFloat64() (float64, float64)

func (*DataSeries) MinValue

func (ds *DataSeries) MinValue() int64

func (*DataSeries) OneItemMaxValue

func (ds *DataSeries) OneItemMaxValue() (DataItem, error)

func (*DataSeries) Pop

func (ds *DataSeries) Pop() (DataItem, error)

func (*DataSeries) SetSeriesName

func (ds *DataSeries) SetSeriesName(seriesName string)

func (*DataSeries) Stats

func (ds *DataSeries) Stats() point.PointSet

func (*DataSeries) ToMonth

func (ds *DataSeries) ToMonth() DataSeries

func (*DataSeries) ToMonthCumulative

func (ds *DataSeries) ToMonthCumulative(timesInput ...time.Time) (DataSeries, error)

func (*DataSeries) ToQuarter

func (ds *DataSeries) ToQuarter() DataSeries

func (*DataSeries) WriteXLSX

func (ds *DataSeries) WriteXLSX(filename, sheetname, col1, col2 string) error

type DataSeriesSet

type DataSeriesSet struct {
	Name     string
	Series   map[string]DataSeries
	Times    []time.Time
	Order    []string
	IsFloat  bool
	Interval timeutil.Interval
}

func NewDataSeriesSet

func NewDataSeriesSet(name string) DataSeriesSet

func (*DataSeriesSet) AddDataSeries

func (set *DataSeriesSet) AddDataSeries(dataSeries ...DataSeries) error

func (*DataSeriesSet) AddItem

func (set *DataSeriesSet) AddItem(item DataItem)

func (*DataSeriesSet) AddItems

func (set *DataSeriesSet) AddItems(items ...DataItem)

func (*DataSeriesSet) DeleteItemByTime

func (set *DataSeriesSet) DeleteItemByTime(dt time.Time)

func (*DataSeriesSet) GetItem

func (set *DataSeriesSet) GetItem(seriesName, rfc3339 string) (DataItem, error)

func (*DataSeriesSet) GetSeriesByIndex

func (set *DataSeriesSet) GetSeriesByIndex(index int) (DataSeries, error)

func (*DataSeriesSet) GetTimeSlice

func (set *DataSeriesSet) GetTimeSlice(sortAsc bool) sortutil.TimeSlice

func (*DataSeriesSet) Inflate

func (set *DataSeriesSet) Inflate()

func (*DataSeriesSet) MinMaxTimes

func (set *DataSeriesSet) MinMaxTimes() (time.Time, time.Time)

func (*DataSeriesSet) MinMaxValues

func (set *DataSeriesSet) MinMaxValues() (int64, int64)

func (*DataSeriesSet) MinMaxValuesFloat64

func (set *DataSeriesSet) MinMaxValuesFloat64() (float64, float64)

func (*DataSeriesSet) PopLast

func (set *DataSeriesSet) PopLast()

func (*DataSeriesSet) SeriesNames

func (set *DataSeriesSet) SeriesNames() []string

func (*DataSeriesSet) TimeStrings

func (set *DataSeriesSet) TimeStrings() []string

func (*DataSeriesSet) ToMonth

func (set *DataSeriesSet) ToMonth() DataSeriesSet

func (*DataSeriesSet) ToMonthCumulative

func (set *DataSeriesSet) ToMonthCumulative(popLast bool) (DataSeriesSet, error)

func (*DataSeriesSet) ToNewSeriesNames added in v1.3.0

func (set *DataSeriesSet) ToNewSeriesNames(seriesNames, seriesSetNames map[string]string) DataSeriesSet

func (*DataSeriesSet) ToTable added in v1.3.0

func (dss *DataSeriesSet) ToTable(opts *DssTableOpts) (table.Table, error)

ToTable returns a `DataSeriesSet` as a `table.TableData`. func DssToTable(dss DataSeriesSet, fmtTime func(time.Time) string) (table.Table, error) {

func (*DataSeriesSet) WriteXLSX added in v1.3.0

func (dss *DataSeriesSet) WriteXLSX(filename string, opts *DssTableOpts) error

type DataSeriesSet2 added in v1.3.0

type DataSeriesSet2 struct {
	Name     string
	SetsMap  map[string]DataSeriesSet
	Interval timeutil.Interval
}

func NewDataSeriesSet2 added in v1.3.0

func NewDataSeriesSet2(name string) DataSeriesSet2

func (*DataSeriesSet2) AddItem added in v1.3.0

func (dss2 *DataSeriesSet2) AddItem(item DataItem)

func (*DataSeriesSet2) AddItems added in v1.3.0

func (dss2 *DataSeriesSet2) AddItems(items ...DataItem)

func (*DataSeriesSet2) SetNamesSorted added in v1.3.0

func (dss2 *DataSeriesSet2) SetNamesSorted() []string

type DssTableOpts added in v1.3.0

type DssTableOpts struct {
	FuncFormatTime func(time.Time) string
	TotalInclude   bool
	TotalTitle     string
	PercentInclude bool
	PercentSuffix  string
}

func (*DssTableOpts) PercentSuffixOrDefault added in v1.3.0

func (opts *DssTableOpts) PercentSuffixOrDefault() string

func (*DssTableOpts) TotalTitleOrDefault added in v1.3.0

func (opts *DssTableOpts) TotalTitleOrDefault() string

type RowFloat64

type RowFloat64 struct {
	Name   string
	Values []float64
}

func ReportFunnelPct

func ReportFunnelPct(rows []RowInt64) []RowFloat64

func ReportGrowthPct

func ReportGrowthPct(rows []RowInt64) []RowFloat64

func (*RowFloat64) Flatten

func (row *RowFloat64) Flatten(conv func(v float64) string, preCount int, preVal string) []string

type RowInt64

type RowInt64 struct {
	Name         string
	DisplayName  string
	HavePlusOne  bool
	ValuePlusOne int64
	Values       []int64
}

func Report

func Report(dss DataSeriesSet, cols int, lowFirst bool) []RowInt64

Report generates data for use with `C3Chart.C3ChartData.Columns`.

func (*RowInt64) Flatten

func (row *RowInt64) Flatten(conv func(v int64) string) []string

type TableConfig added in v1.3.0

type TableConfig struct {
	CountColIdx         uint
	TimeColIdx          uint
	TimeFormat          string
	SeriesSetNameColIdx int // optional. Set < 0 to discard.
	SeriesNameColIdx    int
	Interval            timeutil.Interval
}

func (*TableConfig) GetTimeFormat added in v1.3.0

func (cfg *TableConfig) GetTimeFormat() string

type TimeSeriesFunnel

type TimeSeriesFunnel struct {
	Series map[string]TimeSeriesSimple
	Order  []string
}

func (*TimeSeriesFunnel) DataSeriesSetByQuarter

func (tsf *TimeSeriesFunnel) DataSeriesSetByQuarter() (DataSeriesSet, error)

func (*TimeSeriesFunnel) Times

func (tsf *TimeSeriesFunnel) Times() []time.Time

func (*TimeSeriesFunnel) TimesSorted

func (tsf *TimeSeriesFunnel) TimesSorted() []time.Time

type TimeSeriesSimple

type TimeSeriesSimple struct {
	Name        string
	DisplayName string
	Times       []time.Time
}

func NewTimeSeriesSimple

func NewTimeSeriesSimple(name, displayName string) TimeSeriesSimple

func (*TimeSeriesSimple) ToDataSeriesQuarter

func (tss *TimeSeriesSimple) ToDataSeriesQuarter() DataSeries

type TimeStats

type TimeStats struct {
	Items []DataItem
}

DataItemsStats is used to generate unique counts stats for an array of with time ane names.

func (*TimeStats) UniqueCountsByMonth

func (ts *TimeStats) UniqueCountsByMonth() map[string]int

func (*TimeStats) UniqueCountsByQuarter

func (ts *TimeStats) UniqueCountsByQuarter() map[string]int

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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