-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathoptions.go
92 lines (78 loc) · 1.72 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright ©2020 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package hplot
import (
"gonum.org/v1/plot/vg/draw"
)
// Options encodes various options to pass to a plot.
type Options func(cfg *config)
// Step kind
type StepsKind byte
const (
NoSteps StepsKind = iota
HiSteps
)
type config struct {
bars struct {
xerrs bool
yerrs bool
}
band bool
hinfos HInfos
log struct {
y bool
}
glyph draw.GlyphStyle
steps StepsKind
}
func newConfig(opts []Options) *config {
cfg := new(config)
cfg.steps = NoSteps
for _, opt := range opts {
opt(cfg)
}
return cfg
}
// WithLogY sets whether the plotter in Y should handle log-scale.
func WithLogY(v bool) Options {
return func(c *config) {
c.log.y = v
}
}
// WithXErrBars enables or disables the display of X-error bars.
func WithXErrBars(v bool) Options {
return func(c *config) {
c.bars.xerrs = v
}
}
// WithYErrBars enables or disables the display of Y-error bars.
func WithYErrBars(v bool) Options {
return func(c *config) {
c.bars.yerrs = v
}
}
// WithBand enables or disables the display of a colored band between Y-error bars.
func WithBand(v bool) Options {
return func(c *config) {
c.band = v
}
}
// WithStepsKind sets the style of the connecting line (NoSteps, HiSteps, etc...)
func WithStepsKind(s StepsKind) Options {
return func(c *config) {
c.steps = s
}
}
// WithGlyphStyle sets the glyph style of a plotter.
func WithGlyphStyle(sty draw.GlyphStyle) Options {
return func(c *config) {
c.glyph = sty
}
}
// WithHInfo sets a given histogram info style.
func WithHInfo(v HInfoStyle) Options {
return func(c *config) {
c.hinfos.Style = v
}
}