Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions piechart/sdk/go/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ package pie

import "github.com/perses/perses/go-sdk/common"

func Calculation(calculation common.Calculation) Option {
return func(builder *Builder) error {
builder.Calculation = calculation
return nil
}
}

func WithLegend(legend Legend) Option {
return func(builder *Builder) error {
builder.Legend = &legend
Expand Down
6 changes: 5 additions & 1 deletion piechart/sdk/go/pie.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ func create(options ...Option) (Builder, error) {
PluginSpec: PluginSpec{},
}

for _, opt := range options {
defaults := []Option{
Calculation(common.LastCalculation),
}

for _, opt := range append(defaults, options...) {
if err := opt(builder); err != nil {
return *builder, err
}
Expand Down
Loading