func WithStackdriverTarget(target *stackdriver.Stackdriver) Option {
	return func(heatmap *Heatmap) {
		heatmap.Builder.AddTarget(target.Builder)
	}
}
WithStackdriverTarget adds a stackdriver query to the graph.
package heatmap
import (
	"github.com/K-Phoen/grabana/heatmap/axis"
	"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 DataFormatMode string
const (
	TimeSeriesBuckets DataFormatMode = "tsbuckets"
	TimeSeries DataFormatMode = "timeseries"
)
type LegendOption uint16
const (
	Hide LegendOption = iota
)
type Option func(stat *Heatmap)
type Heatmap struct {
	Builder *sdk.Panel
}
func New(title string, options ...Option) *Heatmap {
	panel := &Heatmap{Builder: sdk.NewHeatmap(title)}
	panel.Builder.IsNew = false
	panel.Builder.HeatmapPanel.Cards = struct {
		CardPadding *float64 `json:"cardPadding"`
		CardRound   *float64 `json:"cardRound"`
	}{}
	panel.Builder.HeatmapPanel.Color = struct {
		CardColor   string   `json:"cardColor"`
		ColorScale  string   `json:"colorScale"`
		ColorScheme string   `json:"colorScheme"`
		Exponent    float64  `json:"exponent"`
		Min         *float64 `json:"min,omitempty"`
		Max         *float64 `json:"max,omitempty"`
		Mode        string   `json:"mode"`
	}{
		CardColor:   "#b4ff00",
		ColorScale:  "sqrt",
		ColorScheme: "interpolateSpectral",
		Exponent:    0.5,
		Mode:        "spectrum",
	}
	panel.Builder.HeatmapPanel.Legend = struct {
		Show bool `json:"show"`
	}{
		Show: true,
	}
	panel.Builder.HeatmapPanel.Tooltip = struct {
		Show          bool `json:"show"`
		ShowHistogram bool `json:"showHistogram"`
	}{
		Show:          true,
		ShowHistogram: true,
	}
	panel.Builder.HeatmapPanel.XAxis = struct {
		Show bool `json:"show"`
	}{
		Show: true,
	}
	panel.Builder.HeatmapPanel.YBucketBound = "auto"
	for _, opt := range append(defaults(), options...) {
		opt(panel)
	}
	return panel
}
func defaults() []Option {
	return []Option{
		Span(6),
		DataFormat(TimeSeriesBuckets),
		HideZeroBuckets(),
		HighlightCards(),
		defaultYAxis(),
	}
}
func defaultYAxis() Option {
	return func(heatmap *Heatmap) {
		heatmap.Builder.HeatmapPanel.YAxis = *axis.New().Builder
	}
}
func DataSource(source string) Option {
	return func(heatmap *Heatmap) {
		heatmap.Builder.Datasource = &source
	}
}
func DataFormat(format DataFormatMode) Option {
	return func(heatmap *Heatmap) {
		heatmap.Builder.HeatmapPanel.DataFormat = string(format)
	}
}
func WithPrometheusTarget(query string, options ...prometheus.Option) Option {
	target := prometheus.New(query, options...)
	return func(heatmap *Heatmap) {
		heatmap.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(heatmap *Heatmap) {
		heatmap.Builder.AddTarget(target.Builder)
	}
}
func WithInfluxDBTarget(query string, options ...influxdb.Option) Option {
	target := influxdb.New(query, options...)
	return func(heatmap *Heatmap) {
		heatmap.Builder.AddTarget(target.Builder)
	}
}