-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalias.go
133 lines (113 loc) · 3.08 KB
/
alias.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package charts
import (
"strconv"
"github.com/go-analyze/charts/chartdraw"
"github.com/go-analyze/charts/chartdraw/drawing"
)
type Box = chartdraw.Box
type Point = chartdraw.Point
type Color = drawing.Color
type FontStyle = chartdraw.FontStyle
var BoxZero = chartdraw.BoxZero
// NewBox returns a new box with the provided top, bottom, left, and right sizes.
func NewBox(top, bottom, left, right int) Box {
return Box{
IsSet: true,
Top: top,
Bottom: bottom,
Left: left,
Right: right,
}
}
// NewBoxEqual returns a new box with equal sizes to each side.
func NewBoxEqual(size int) Box {
return NewBox(size, size, size, size)
}
// NewFontStyleWithSize constructs a new FontStyle with the specified font size. If you want to avoid directly
// constructing the FontStyle struct, you can use this followed by additional `WithX` function calls on the returned
// FontStyle.
func NewFontStyleWithSize(size float64) FontStyle {
return FontStyle{
FontSize: size,
}
}
// OffsetInt provides an ability to configure a shift from the top or left alignments.
type OffsetInt struct {
// Left indicates a vertical spacing adjustment from the top.
Top int
// Left indicates a horizontal spacing adjustment from the left.
Left int
}
func (o OffsetInt) WithTop(val int) OffsetInt {
return OffsetInt{
Left: o.Left,
Top: val,
}
}
func (o OffsetInt) WithLeft(val int) OffsetInt {
return OffsetInt{
Left: val,
Top: o.Top,
}
}
// OffsetStr provides an ability to configure a shift from the top or left alignments using flexible string inputs.
type OffsetStr struct {
// Left is the distance between the component and the left side of the container.
// It can be pixel value (20), percentage value (20%), or position description: 'left', 'right', 'center'.
Left string
// Top is the distance between the component and the top side of the container.
// It can be pixel value (20), or percentage value (20%), or position description: 'top', 'bottom'.
Top string
}
var OffsetLeft = OffsetStr{Left: PositionLeft}
var OffsetRight = OffsetStr{Left: PositionRight}
var OffsetCenter = OffsetStr{Left: PositionCenter}
func (o OffsetStr) WithTop(val string) OffsetStr {
return OffsetStr{
Left: o.Left,
Top: val,
}
}
func (o OffsetStr) WithTopI(val int) OffsetStr {
return OffsetStr{
Left: o.Left,
Top: strconv.Itoa(val),
}
}
func (o OffsetStr) WithLeft(val string) OffsetStr {
return OffsetStr{
Left: val,
Top: o.Top,
}
}
func (o OffsetStr) WithLeftI(val int) OffsetStr {
return OffsetStr{
Left: strconv.Itoa(val),
Top: o.Top,
}
}
const (
ChartTypeLine = "line"
ChartTypeBar = "bar"
ChartTypePie = "pie"
ChartTypeRadar = "radar"
ChartTypeFunnel = "funnel"
ChartTypeHorizontalBar = "horizontalBar"
)
const (
ChartOutputSVG = "svg"
ChartOutputPNG = "png"
chartDefaultOutputFormat = ChartOutputPNG
)
const (
PositionLeft = "left"
PositionRight = "right"
PositionCenter = "center"
PositionTop = "top"
PositionBottom = "bottom"
)
const (
AlignLeft = "left"
AlignRight = "right"
AlignCenter = "center"
)