feat: support box option for chart

This commit is contained in:
vicanso 2022-02-12 12:41:14 +08:00
parent 4262b148ca
commit bff06b2aa5
3 changed files with 17 additions and 219 deletions

10
draw.go
View file

@ -71,6 +71,16 @@ func PaddingOption(padding chart.Box) Option {
}
}
func BoxOption(box chart.Box) Option {
return func(d *Draw) error {
if box.IsZero() {
return nil
}
d.Box = box
return nil
}
}
func NewDraw(opt DrawOption, opts ...Option) (*Draw, error) {
if opt.Parent == nil && (opt.Width <= 0 || opt.Height <= 0) {
return nil, errors.New("parent and width/height can not be nil")