func Thresholds(values [2]string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.Thresholds = strings.Join([]string{values[0], values[1]}, ",")
	}
}
Thresholds change the background and value colors dynamically within the
panel, depending on the Singlestat value. The threshold is defined by 2
values which represent 3 ranges that correspond to the three colors directly
to the right.
package singlestat
import (
	"strings"
	"github.com/K-Phoen/grabana/target/graphite"
	"github.com/K-Phoen/grabana/target/influxdb"
	"github.com/K-Phoen/grabana/target/prometheus"
	"github.com/K-Phoen/grabana/target/stackdriver"
	"github.com/grafana-tools/sdk"
)
type Option func(stat *SingleStat)
type StatType string
const (
	Min StatType = "min"
	Max StatType = "max"
	Avg StatType = "avg"
	Current StatType = "current"
	Total StatType = "total"
	First StatType = "first"
	Delta StatType = "delta"
	Diff StatType = "diff"
	Range StatType = "range"
	Name StatType = "name"
)
type ValueMap struct {
	Value string
	Text  string
}
type RangeMap struct {
	From string
	To   string
	Text string
}
var valueToTextMapping = 1
var rangeToTextMapping = 2
type SingleStat struct {
	Builder *sdk.Panel
}
func New(title string, options ...Option) *SingleStat {
	panel := &SingleStat{Builder: sdk.NewSinglestat(title)}
	valueToText := "value to text"
	rangeToText := "range to text"
	panel.Builder.IsNew = false
	mappingType := uint(valueToTextMapping)
	panel.Builder.SinglestatPanel.MappingType = &mappingType
	panel.Builder.SinglestatPanel.MappingTypes = []*sdk.MapType{
		{
			Name:  &valueToText,
			Value: &valueToTextMapping,
		},
		{
			Name:  &rangeToText,
			Value: &rangeToTextMapping,
		},
	}
	panel.Builder.SinglestatPanel.SparkLine = sdk.SparkLine{}
	for _, opt := range append(defaults(), options...) {
		opt(panel)
	}
	return panel
}
func defaults() []Option {
	return []Option{
		Span(6),
		ValueFontSize("100%"),
		ValueType(Avg),
		Colors([3]string{"#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"}),
		ValuesToText([]ValueMap{
			{
				Value: "null",
				Text:  "N/A",
			},
		}),
		SparkLineColor("rgb(31, 120, 193)"),
		SparkLineFillColor("rgba(31, 118, 189, 0.18)"),
	}
}
func DataSource(source string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.Datasource = &source
	}
}
func WithPrometheusTarget(query string, options ...prometheus.Option) Option {
	target := prometheus.New(query, options...)
	return func(singleStat *SingleStat) {
		singleStat.Builder.AddTarget(&sdk.Target{
			RefID:          target.Ref,
			Expr:           target.Expr,
			IntervalFactor: target.IntervalFactor,
			Interval:       target.Interval,
			Step:           target.Step,
			LegendFormat:   target.LegendFormat,
			Instant:        target.Instant,
			Format:         target.Format,
		})
	}
}
func WithGraphiteTarget(query string, options ...graphite.Option) Option {
	target := graphite.New(query, options...)
	return func(singleStat *SingleStat) {
		singleStat.Builder.AddTarget(target.Builder)
	}
}
func WithInfluxDBTarget(query string, options ...influxdb.Option) Option {
	target := influxdb.New(query, options...)
	return func(singleStat *SingleStat) {
		singleStat.Builder.AddTarget(target.Builder)
	}
}
func WithStackdriverTarget(target *stackdriver.Stackdriver) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.AddTarget(target.Builder)
	}
}
func Span(span float32) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.Span = span
	}
}
func Height(height string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.Height = &height
	}
}
func Description(content string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.Description = &content
	}
}
func Transparent() Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.Transparent = true
	}
}
func Unit(unit string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.Format = unit
	}
}
func Decimals(count int) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.Decimals = count
	}
}
func SparkLine() Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.Show = true
		singleStat.Builder.SinglestatPanel.SparkLine.Full = false
	}
}
func FullSparkLine() Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.Show = true
		singleStat.Builder.SinglestatPanel.SparkLine.Full = true
	}
}
func SparkLineColor(color string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.LineColor = &color
	}
}
func SparkLineFillColor(color string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.FillColor = &color
	}
}
func SparkLineYMin(value float64) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.YMin = &value
	}
}
func SparkLineYMax(value float64) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.SparkLine.YMax = &value
	}
}
func ValueType(valueType StatType) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.ValueName = string(valueType)
	}
}
func ValueFontSize(size string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.ValueFontSize = size
	}
}
func Prefix(prefix string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.Prefix = &prefix
	}
}
func PrefixFontSize(size string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.PrefixFontSize = &size
	}
}
func Postfix(postfix string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.Postfix = &postfix
	}
}
func PostfixFontSize(size string) Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.PostfixFontSize = &size
	}
}
func ColorValue() Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.ColorValue = true
	}
}
func ColorBackground() Option {
	return func(singleStat *SingleStat) {
		singleStat.Builder.SinglestatPanel.ColorBackground = true
	}
}