Documentation ¶
Overview ¶
statictimeseriesdata provides tools for adding and formatting static time series data for reporting purposes.
Index ¶
- func DataSeriesItemTimes(series *DataSeries) []time.Time
- func DataSeriesMapMinMaxTimes(dsm map[string]DataSeries) (time.Time, time.Time, error)
- func DataSeriesMapMinMaxValues(dsm map[string]DataSeries) (int64, int64, error)
- func DataSeriesMinMaxTimes(series *DataSeries) (time.Time, time.Time)
- func DataSeriesSliceNames(dsSlice []DataSeries) []string
- func DataSeriesSliceTable(dsSlice []DataSeries) table.Table
- func DataSeriesSliceTimes(dsSlice []DataSeries) []string
- func DataSeriesSliceWriteXLSX(filename string, dsSlice []DataSeries) error
- func DataSeriesTimeSeries(series *DataSeries, interval timeutil.Interval) []time.Time
- func DataSeriesToTable(ds DataSeries, col2 string, dtFmt func(dt time.Time) string) table.Table
- func DataSeriesWriteXLSX(filename string, ds DataSeries, col2 string, dtFmt func(dt time.Time) string) error
- func MSS2MS(in map[string]map[string]int) map[string]int
- func ReportAxisX(dss DataSeriesSet, cols int, conv func(time.Time) string) []string
- func TimeFormatNiceMonth(dt time.Time) string
- func TimeFormatNiceQuarter(dt time.Time) string
- func TimeFormatRFC3339(dt time.Time) string
- type DataItem
- type DataSeries
- func (ds *DataSeries) AddItem(item DataItem)
- func (ds *DataSeries) DeleteByTime(dt time.Time)
- func (ds *DataSeries) GetTimeSlice(sortSlice bool) timeutil.TimeSlice
- func (ds *DataSeries) ItemsSorted() []DataItem
- func (ds *DataSeries) Keys() []string
- func (ds *DataSeries) Last() (DataItem, error)
- func (ds *DataSeries) LastItem(skipIfTimePartialValueLessPrev bool) (DataItem, error)
- func (ds *DataSeries) MaxValue() int64
- func (series *DataSeries) MinMaxTimes() (time.Time, time.Time)
- func (ds *DataSeries) MinMaxValues() (int64, int64)
- func (ds *DataSeries) MinMaxValuesFloat64() (float64, float64)
- func (ds *DataSeries) MinValue() int64
- func (ds *DataSeries) OneItemMaxValue() (DataItem, error)
- func (ds *DataSeries) Pop() (DataItem, error)
- func (ds *DataSeries) SetSeriesName(seriesName string)
- func (ds *DataSeries) Stats() point.PointSet
- func (ds *DataSeries) ToMonth() DataSeries
- func (ds *DataSeries) ToMonthCumulative(timesInput ...time.Time) (DataSeries, error)
- func (ds *DataSeries) ToQuarter() DataSeries
- func (ds *DataSeries) WriteXLSX(filename, sheetname, col1, col2 string) error
- type DataSeriesSet
- func (set *DataSeriesSet) AddDataSeries(dataSeries ...DataSeries) error
- func (set *DataSeriesSet) AddItem(item DataItem)
- func (set *DataSeriesSet) AddItems(items ...DataItem)
- func (set *DataSeriesSet) DeleteItemByTime(dt time.Time)
- func (set *DataSeriesSet) GetItem(seriesName, rfc3339 string) (DataItem, error)
- func (set *DataSeriesSet) GetSeriesByIndex(index int) (DataSeries, error)
- func (set *DataSeriesSet) GetTimeSlice(sortAsc bool) sortutil.TimeSlice
- func (set *DataSeriesSet) Inflate()
- func (set *DataSeriesSet) MinMaxTimes() (time.Time, time.Time)
- func (set *DataSeriesSet) MinMaxValues() (int64, int64)
- func (set *DataSeriesSet) MinMaxValuesFloat64() (float64, float64)
- func (set *DataSeriesSet) PopLast()
- func (set *DataSeriesSet) SeriesNames() []string
- func (set *DataSeriesSet) TimeStrings() []string
- func (set *DataSeriesSet) ToMonth() DataSeriesSet
- func (set *DataSeriesSet) ToMonthCumulative(popLast bool) (DataSeriesSet, error)
- func (set *DataSeriesSet) ToNewSeriesNames(seriesNames, seriesSetNames map[string]string) DataSeriesSet
- func (dss *DataSeriesSet) ToTable(opts *DssTableOpts) (table.Table, error)
- func (dss *DataSeriesSet) WriteXLSX(filename string, opts *DssTableOpts) error
- type DataSeriesSet2
- type DssTableOpts
- type RowFloat64
- type RowInt64
- type TableConfig
- type TimeSeriesFunnel
- type TimeSeriesSimple
- type TimeStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataSeriesItemTimes ¶
func DataSeriesItemTimes(series *DataSeries) []time.Time
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 ¶
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 ReportAxisX ¶
ReportAxisX generates data for use with `C3Chart.C3Axis.C3AxisX.Categories`.
func TimeFormatNiceMonth ¶
func TimeFormatNiceQuarter ¶
func TimeFormatRFC3339 ¶
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 (*DataItem) ValueInt64 ¶
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 ¶
func ReportFunnelPct ¶
func ReportFunnelPct(rows []RowInt64) []RowFloat64
func ReportGrowthPct ¶
func ReportGrowthPct(rows []RowInt64) []RowFloat64
type RowInt64 ¶
type RowInt64 struct { Name string DisplayName string HavePlusOne bool ValuePlusOne int64 Values []int64 }
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 ¶
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.