Documentation
¶
Overview ¶
Package geom holds the visual marks a chart is made of.
A geom knows what its shape is and never how it is rendered: it reads columns, asks the scales where values go, and emits IR. It has no reference to a backend, no knowledge of SVG or raster, and no opinion about layout beyond the rectangle it is given.
Index ¶
- Variables
- type Frame
- type Geom
- type LegendEntry
- type Missing
- type Option
- func BarWidth(f float64) Option
- func Baseline(v float64) Option
- func Color(col ir.Color) Option
- func Dash(pattern ...float32) Option
- func Fill(col ir.Color) Option
- func Label(s string) Option
- func OnMissing(m Missing) Option
- func Shape(m ir.Marker) Option
- func Size(s float32) Option
- func Tension(t float64) Option
- func Width(w float32) Option
- func X(col string) Option
- func Y(col string) Option
- type SwatchKind
Constants ¶
This section is empty.
Variables ¶
var ErrNoColumn = errors.New("refract/geom: column not found")
ErrNoColumn reports a column named by an option that the source does not have. It is returned rather than panicking because the column name usually comes from user input or a config file.
Functions ¶
This section is empty.
Types ¶
type Frame ¶
type Frame struct {
// Area is the plot rectangle in device space. Scales already map into it.
Area ir.Rect
// X and Y are the trained, ranged scales.
X, Y scale.Scale
// Theme supplies defaults the geom did not override.
Theme theme.Theme
// Index is the geom's position among the chart's layers, used to pick a
// default colour from the palette.
Index int
}
Frame is everything a geom needs to turn data into IR.
type Geom ¶
type Geom interface {
// Train feeds the geom's data into the scales so they can establish their
// domains. It runs before layout, because layout needs tick labels and
// tick labels need a domain.
Train(x, y scale.Scale) error
// Build emits the geom's marks into b.
Build(b ir.Backend, f Frame) error
// Legend returns the entry this geom contributes, or ok == false if it
// should not appear in the legend.
Legend(f Frame) (LegendEntry, bool)
}
Geom is a layer of marks.
type LegendEntry ¶
type LegendEntry struct {
Label string
Color ir.Color
Kind SwatchKind
Marker ir.Marker
Dash []float32
Width float32
}
LegendEntry is a geom's contribution to the legend.
type Option ¶
type Option func(*config)
Option configures a geom. Options are shared across geom constructors: an option a given geom has no use for is accepted and ignored, which keeps the API one namespace instead of six.
func BarWidth ¶
BarWidth sets bar width as a fraction of the spacing between adjacent bars, in (0, 1]. The default is 0.8.
func Dash ¶
Dash sets a dash pattern in device units. Dashing a series is redundant encoding: it keeps the chart readable in greyscale and for colourblind readers.
type SwatchKind ¶
type SwatchKind uint8
SwatchKind is how a legend entry draws its sample.
const ( SwatchLine SwatchKind = iota SwatchMarker SwatchBox )
The swatch kinds.