Documentation ¶
Index ¶
- func SecondsFromTime(time time.Time) float64
- func TimeFromSeconds(seconds float64) time.Time
- type Aggregator
- type Axis
- type BezierPoint
- type Capper
- type LegendPosition
- type Margaid
- func (m *Margaid) Axis(series *Series, axis Axis, ticker Ticker, grid bool, title string)
- func (m *Margaid) Bar(series []*Series, using ...Using)
- func (m *Margaid) Frame()
- func (m *Margaid) LabeledTicker(labeler func(float64) string) Ticker
- func (m *Margaid) Legend(position LegendPosition)
- func (m *Margaid) Line(series *Series, using ...Using)
- func (m *Margaid) Render(writer io.Writer) error
- func (m *Margaid) Smooth(series *Series, using ...Using)
- func (m *Margaid) TimeTicker(format string) Ticker
- func (m *Margaid) Title(title string)
- func (m *Margaid) ValueTicker(style byte, precision int, base int) Ticker
- type Option
- func WithAutorange(axis Axis, series ...*Series) Option
- func WithBackgroundColor(background string) Option
- func WithColorScheme(scheme int) Option
- func WithInset(inset float64) Option
- func WithLabelFont(family string, size int) Option
- func WithPadding(padding float64) Option
- func WithProjection(axis Axis, proj Projection) Option
- func WithRange(axis Axis, min, max float64) Option
- func WithTitleFont(family string, size int) Option
- type Projection
- type Series
- type SeriesIterator
- type SeriesOption
- type Ticker
- type Using
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SecondsFromTime ¶
SecondsFromTime converts from time.Time to seconds since the epoch
func TimeFromSeconds ¶
TimeFromSeconds converts from seconds since the epoch to time.Time
Types ¶
type Aggregator ¶
Aggregator is the aggregating function type
type BezierPoint ¶
type BezierPoint [3]struct{ X, Y float64 }
BezierPoint is one Bezier curve control point
type LegendPosition ¶
type LegendPosition int
LegendPosition decides where to draw the legend
const ( RightTop LegendPosition = iota + 'l' RightBottom BottomLeft )
LegendPosition constants
type Margaid ¶
type Margaid struct {
// contains filtered or unexported fields
}
Margaid == diagraM
func (*Margaid) LabeledTicker ¶
LabeledTicker places tick marks and labels for all values of a series. The labels are provided by the labeler function.
func (*Margaid) Legend ¶
func (m *Margaid) Legend(position LegendPosition)
Legend draws a legend for named plots. If position is set to BottomLeft, it will grow the plot size to accommodate the number of legends displayed.
func (*Margaid) TimeTicker ¶
TimeTicker returns time valued tick labels in the specified time format. TimeTicker assumes that time is linear.
type Option ¶
type Option func(*Margaid)
Option is the base type for all series options
func WithAutorange ¶
WithAutorange sets range for an axis from the values of one or more series
func WithBackgroundColor ¶ added in v0.2.0
WithBackgroundColor sets the chart background color as a valid SVG color attribute string. Default is transparent.
func WithColorScheme ¶
WithColorScheme sets the start color for selecting plot colors. The start color is selected as a hue value between 0 and 359.
func WithLabelFont ¶
WithLabelFont sets label font family and size in pixels
func WithPadding ¶
WithPadding sets the padding inside the plotting area as a percentage [0..20] of the area width and height
func WithProjection ¶
func WithProjection(axis Axis, proj Projection) Option
WithProjection sets the projection for a given axis
func WithTitleFont ¶
WithTitleFont sets title font family and size in pixels
type Projection ¶
type Projection int
Projection is the type for the projection constants
const ( Lin Projection = iota + 'p' Log )
Projection constants
type Series ¶
type Series struct {
// contains filtered or unexported fields
}
Series is the plottable type in Margaid
func (*Series) Add ¶
Add appends one or more values, optionally peforming aggregation. If the series is capped, capping will be applied after aggregation.
func (*Series) Values ¶
func (s *Series) Values() SeriesIterator
Values returns an iterator to the series values
type SeriesIterator ¶
type SeriesIterator struct {
// contains filtered or unexported fields
}
SeriesIterator helps iterating series values
func (*SeriesIterator) Get ¶
func (si *SeriesIterator) Get() Value
Get returns the iterator current value. A newly created iterator has no current value.
func (*SeriesIterator) Next ¶
func (si *SeriesIterator) Next() bool
Next steps to the next value. A newly created iterator has no current value.
type SeriesOption ¶
type SeriesOption func(s *Series)
SeriesOption is the base type for all series options
func AggregatedBy ¶
func AggregatedBy(f Aggregator, interval time.Duration) SeriesOption
AggregatedBy sets the series aggregator
func CappedByAge ¶
func CappedByAge(cap time.Duration, reference func() time.Time) SeriesOption
CappedByAge caps a series by removing values older than cap in relation to the current value of the reference funcion.
func CappedBySize ¶
func CappedBySize(cap int) SeriesOption
CappedBySize caps a series to at most cap values.
type Ticker ¶
type Ticker interface {
// contains filtered or unexported methods
}
Ticker provides tick marks and labels for axes
type Using ¶
type Using func(*plotOptions)
Using is the base type for plotting options
func UsingMarker ¶
UsingMarker selects a marker for highlighting plotted values. See svg.Marker for valid marker types.
func UsingStrokeWidth ¶ added in v0.1.0
type Value ¶
Value is the type of each series element. The X part represents a position on the X axis, which could be time or a regular value.
func Avg ¶
Avg calculates the Y average of a list of values, reported as observed at the given time.
func Delta ¶
Delta calculates the Y difference between the first and last value in the list, reported as observed at the given time.