Documentation
¶
Index ¶
- func DurationTo(durations []time.Duration, scale time.Duration) []float64
- func DurationToNanoseconds(durations []time.Duration) []float64
- func DurationToSeconds(durations []time.Duration) []float64
- func Int32sToFloat64s(xs []int32) []float64
- func Int64sToFloat64s(xs []int64) []float64
- func IntsToFloat64s(xs []int) []float64
- type AutomaticTicks
- type Axis
- func (axis *Axis) FromCanvas(s Length, screenMin, screenMax Length) float64
- func (axis *Axis) Include(min, max float64)
- func (axis *Axis) IsValid() bool
- func (axis *Axis) MakeNice()
- func (axis *Axis) SetScreenLog1P(compress float64)
- func (axis *Axis) ToCanvas(v float64, screenMin, screenMax Length) Length
- type AxisGroup
- type AxisTransform
- type Bar
- type Canvas
- type Dataset
- type Density
- type Element
- type Elements
- type Gizmo
- type Grid
- type GridTheme
- type HFlex
- type HStack
- type Label
- type Length
- type Line
- type Log1pTransform
- type ManualTicks
- type Margin
- type OptimizedLine
- type PercentileTransform
- type Percentiles
- type Plot
- type Point
- type Rect
- func (r Rect) Column(i, count int) Rect
- func (r Rect) Empty() bool
- func (r Rect) Inset(by Rect) Rect
- func (r Rect) Offset(by Point) Rect
- func (r Rect) Points() []Point
- func (r Rect) Row(i, count int) Rect
- func (r Rect) Shrink(radius Point) Rect
- func (r Rect) Size() Point
- func (r Rect) UnitLocation(u Point) Point
- func (r Rect) Zero() Rect
- type ScreenSpaceTransform
- type Stats
- type Style
- type Textbox
- type Theme
- type Tick
- type TickLabels
- type TickLabelsX
- type TickLabelsY
- type Ticks
- type VFlex
- type VStack
- type Violin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationTo ¶
DurationTo converts durations to the specified scale.
func DurationToNanoseconds ¶
DurationToNanoseconds converts an slice of durations to nanoseconds.
func DurationToSeconds ¶
DurationToSeconds converts an slice of durations to seconds.
func Int32sToFloat64s ¶
Int32sToFloat64s convers a slice of int32-s to float64-s.
func Int64sToFloat64s ¶
Int64sToFloat64s convers a slice of int64-s to float64-s.
func IntsToFloat64s ¶
IntssToFloat64s convers a slice of ints to float64-s.
Types ¶
type AutomaticTicks ¶
type AutomaticTicks struct{}
AutomaticTicks tries to automatically figure out which ticks to use.
func (AutomaticTicks) Ticks ¶
func (ticks AutomaticTicks) Ticks(axis *Axis) []Tick
Ticks automatically calculates appropriate ticks for an axis.
type Axis ¶
type Axis struct {
// Min value of the axis (in value space)
Min float64
// Max value of the axis (in value space)
Max float64
Flip bool
Ticks Ticks
MajorTicks int
MinorTicks int
Transform AxisTransform
}
Axis defines an axis that defines how values are transformed to canvas space.
func NewPercentilesAxis ¶
func NewPercentilesAxis() *Axis
NewPercentilesAxis creates X axis for plotting percentiles. It uses 5 digits of precision max.
func (*Axis) FromCanvas ¶
FromCanvas converts canvas point to value point.
func (*Axis) MakeNice ¶
func (axis *Axis) MakeNice()
MakeNice tries to adjust min, max such they look nice given the MajorTicks and MinorTicks.
func (*Axis) SetScreenLog1P ¶
SetScreenLog1P sets axis to logarithm space.
type AxisGroup ¶
AxisGroup allows sub-elements to have different different axes defined rather than the top-level plot.
func NewAxisGroup ¶
NewAxisGroup creates a new axis group.
type AxisTransform ¶
type AxisTransform interface {
ToCanvas(axis *Axis, v float64, screenMin, screenMax Length) Length
FromCanvas(axis *Axis, s Length, screenMin, screenMax Length) float64
}
AxisTransform transforms values between canvas and value-space.
type Bar ¶
Bar implements a stacked-bar plot.
type Canvas ¶
type Canvas interface {
Bounds() Rect
Layer(index int) Canvas
Clip(r Rect) Canvas
Context(r Rect) Canvas
Text(text string, at Point, style *Style)
Poly(points []Point, style *Style)
Rect(r Rect, style *Style)
}
Canvas describes interface for drawing graphics.
type Density ¶
Density implements density plot using cubic-pulse kernel.
func NewDensity ¶
NewDensity creates a density plot from the given values.
type Elements ¶
type Elements []Element
Elements defines a list of elements.
type HFlex ¶
type HFlex struct {
Margin Rect
// contains filtered or unexported fields
}
HFlex implements horizontally stacked elements with non-equal sizes.
type HStack ¶
HStack implements horizontally stacked elements.
type Label ¶
Label describes a plot element that draws a text to relative position.
type Line ¶
Line implements a simple line plot.
type Log1pTransform ¶
type Log1pTransform struct {
// contains filtered or unexported fields
}
Log1pTransform implements logarithmic transform.
func NewLog1pTransform ¶
func NewLog1pTransform(base float64) *Log1pTransform
NewLog1pTransform implements a logarithmic axis transform.
func (*Log1pTransform) FromCanvas ¶
func (tx *Log1pTransform) FromCanvas(axis *Axis, s Length, screenMin, screenMax Length) float64
FromCanvas converts canvas point to value point.
type ManualTicks ¶
type ManualTicks []Tick
ManualTicks allows to manually place and label ticks.
func (ManualTicks) Ticks ¶
func (ticks ManualTicks) Ticks(axis *Axis) []Tick
Ticks calculates ticks for specified axis.
type Margin ¶
Margin is a collection which is drawn with a margin.
type OptimizedLine ¶
OptimizedLine implements a simple line plot.
func NewOptimizedLine ¶
func NewOptimizedLine(label string, points []Point, thresholdPx float64) *OptimizedLine
NewOptimizedLine creates a new line element that tries to optimize drawing.
func (*OptimizedLine) Draw ¶
func (line *OptimizedLine) Draw(plot *Plot, canvas Canvas)
Draw draws the element to canvas.
func (*OptimizedLine) Stats ¶
func (line *OptimizedLine) Stats() Stats
Stats calculates element statistics.
type PercentileTransform ¶
type PercentileTransform struct {
// contains filtered or unexported fields
}
PercentilesTransform implements axis transform for percentiles X axis.
func NewPercentileTransform ¶
func NewPercentileTransform(levels int) *PercentileTransform
NewPercentileTransform creates a transform for X axis with the specified max levels.
func (*PercentileTransform) FromCanvas ¶
func (tx *PercentileTransform) FromCanvas(axis *Axis, s Length, screenMin, screenMax Length) float64
FromCanvas converts screen value s to value.
type Percentiles ¶
Percentiles implements drawing percentile line.
func NewPercentiles ¶
func NewPercentiles(label string, values []float64) *Percentiles
NewPercentiles creates percentiles from values.
func (*Percentiles) Draw ¶
func (line *Percentiles) Draw(plot *Plot, canvas Canvas)
Draw draws the element to canvas.
func (*Percentiles) Stats ¶
func (line *Percentiles) Stats() Stats
Stats calculates element statistics.
type Plot ¶
type Plot struct {
// X, Y are the axis information
X, Y *Axis
Margin Rect
Elements
// DefaultStyle
Theme
}
Plot defines a combination of elements that can be drawn to the canvas.
type Point ¶
type Point struct{ X, Y Length }
Point describes a canvas position or offset.
type Rect ¶
type Rect struct{ Min, Max Point }
Rect defines a position.
func (Rect) UnitLocation ¶
UnitLocation converts relative position to rect bounds.
type ScreenSpaceTransform ¶
type ScreenSpaceTransform struct {
Transform func(v float64) float64
Inverse func(v float64) float64
}
ScreenSpaceTransform transforms using a custom func.
func (*ScreenSpaceTransform) FromCanvas ¶
func (tx *ScreenSpaceTransform) FromCanvas(axis *Axis, s Length, screenMin, screenMax Length) float64
FromCanvas converts canvas point to value point.
type Stats ¶
Stats describes a data points.
func PointsStats ¶
PointsStats calculates statistics of points.
type Style ¶
type Style struct {
Stroke color.Color
Fill color.Color
Size Length
// line only
Dash []Length
DashOffset []Length
// text only
Font string
Rotation float64
Origin Point // {-1..1, -1..1}
// SVG
Class string
}
Style represents a drawing style for an element.
type Textbox ¶
Textbox implements drawing text on plots.
func NewTextbox ¶
NewTextbox creates a new text graphic with the specified lines.
type TickLabels ¶
type TickLabels struct {
X *TickLabelsX
Y *TickLabelsY
}
TickLabels implements drawing tick labels.
func NewTickLabels ¶
func NewTickLabels() *TickLabels
NewTickLabels creates a new tick labelling element.
func (*TickLabels) Draw ¶
func (labels *TickLabels) Draw(plot *Plot, canvas Canvas)
Draw draws tick labels to canvas using axes from plot.
type TickLabelsX ¶
type TickLabelsX struct {
Enabled bool
// Side determines position of the labels. -1 = min, 0 = center, 1 = max
Side float64
Style Style
}
TickLabelsX implements drawing tick labels.
func NewTickLabelsX ¶
func NewTickLabelsX() *TickLabelsX
NewTickLabelsX creates a new tick labelling element for X axis.
func (*TickLabelsX) Draw ¶
func (labels *TickLabelsX) Draw(plot *Plot, canvas Canvas)
Draw draws tick labels to canvas using axes from plot.
type TickLabelsY ¶
type TickLabelsY struct {
Enabled bool
// Side determines position of the labels. -1 = min, 0 = center, 1 = max
Side float64
Style Style
}
TickLabelsY implements drawing tick labels.
func NewTickLabelsY ¶
func NewTickLabelsY() *TickLabelsY
NewTickLabelsY creates a new tick labelling element for X axis.
func (*TickLabelsY) Draw ¶
func (labels *TickLabelsY) Draw(plot *Plot, canvas Canvas)
Draw draws tick labels to canvas using axes from plot.
type VFlex ¶
type VFlex struct {
Margin Rect
// contains filtered or unexported fields
}
VFlex implements horizontally stacked elements with non-equal sizes.
type VStack ¶
VStack implements vertically stacked elements.
type Violin ¶
type Violin struct {
Style
Label string
Side float64
Kernel Length
Normalized bool
Data []float64 // sorted
}
Violin implements violin plot using cubic-pulse for kernel function.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
canvas-example
command
|
|
|
plot-commit-lifetime
command
|
|
|
plot-example
command
|
|
|
plotgio
module
|
|