-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
63 lines (54 loc) · 1.27 KB
/
option.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
package gopster
// Option configures a chart.
type Option func(*Chart)
// Title sets a chart's title. Defaults to an empty string.
func Title(t string) Option {
return func(c *Chart) {
c.title = t
}
}
// Width sets a chart's width. Defaults to 3.
func Width(w int) Option {
return func(c *Chart) {
c.width = w
}
}
// Height sets a chart's height. Defaults to 3.
func Height(h int) Option {
return func(c *Chart) {
c.height = h
}
}
// ShowNumbers toggles number rendering on a chart. Defaults to false.
// ShowTitles must also be true for this to work.
func ShowNumbers() Option {
return func(c *Chart) {
c.showNumbers = true
}
}
// ShowTitles toggles title rendering on a chart. Defaults to false.
func ShowTitles() Option {
return func(c *Chart) {
c.showTitles = true
}
}
// Gap sets a chart's gap. Defaults to 20.
func Gap(g float64) Option {
return func(c *Chart) {
c.gap = g
}
}
// BackgroundColor sets a chart's background color. Must be a valid hex color string.
// Defaults to black.
func BackgroundColor(bc string) Option {
return func(c *Chart) {
c.backgroundColor = bc
}
}
// TextColor sets a chart's text color. Must be a valid hex color string.
// Defaults to white.
func TextColor(tc string) Option {
return func(c *Chart) {
c.textColor = tc
}
}