Documentation
¶
Index ¶
- Constants
- Variables
- func IsTSXFile(name string) bool
- func ResolveDateExpression(expr string) string
- func ResolveDatePreset(key string) map[string]any
- func Validate(d *Dashboard) error
- func ValidateAll(dashboards []*Dashboard) error
- type AxisEncoding
- func (a *AxisEncoding) FieldList() []string
- func (a *AxisEncoding) FieldString() string
- func (a *AxisEncoding) MarshalJSON() ([]byte, error)
- func (a *AxisEncoding) MarshalYAML() (any, error)
- func (a *AxisEncoding) UnmarshalJSON(data []byte) error
- func (a *AxisEncoding) UnmarshalYAML(node *yaml.Node) error
- type BoundEncoding
- type ColorEncoding
- type ColorScale
- type Dashboard
- func FindByName(dashboards []*Dashboard, name string) *Dashboard
- func LoadDir(dir string, opts ...TSXOption) ([]*Dashboard, error)
- func LoadFile(path string) (*Dashboard, error)
- func LoadOneByName(dir, name string, opts ...TSXOption) (*Dashboard, error)
- func LoadTSXFile(path string, opts ...TSXOption) (*Dashboard, error)
- func (d *Dashboard) DateRangeFilterName() string
- func (d *Dashboard) DefaultFilters() map[string]any
- func (d *Dashboard) ResolveSemanticModel(ref string) (*sem.Model, string, error)
- func (d *Dashboard) ResolveWidgetSemanticJob(w *Widget) (*SemanticJob, bool, error)
- func (d *Dashboard) SetProjectContext(projectRoot string, semanticModels map[string]*sem.Model, ...)
- type Filter
- type FilterOptions
- type FormatLayer
- type NoQueryError
- type PivotConfig
- type PivotField
- type PivotValue
- type ProjectPaths
- type Query
- type QueryNotFoundError
- type RefBand
- type RefLine
- type Row
- type SemanticDimensionRef
- type SemanticJob
- type SemanticQueryFilter
- type SemanticSort
- type SeriesStyle
- type SliceStyle
- type TSXOption
- type TableColumn
- type ValidationError
- type ValidationSetError
- type ValueEncoding
- type Widget
- func (w *Widget) ColorField() string
- func (w *Widget) HasInlineData() bool
- func (w *Widget) IsSemantic() bool
- func (w *Widget) ResolvedQuery(dashboard *Dashboard) (sql, connection string, err error)
- func (w *Widget) ValueField() string
- func (w *Widget) XField() string
- func (w *Widget) Y2Fields() []string
- func (w *Widget) YFields() []string
- type WidgetData
Constants ¶
const ( WidgetTypeMetric = "metric" WidgetTypeChart = "chart" WidgetTypeTable = "table" WidgetTypePivotTable = "pivot_table" WidgetTypeText = "text" WidgetTypeDivider = "divider" WidgetTypeImage = "image" )
Widget type constants.
const ( CondIsEmpty = "is_empty" CondIsNotEmpty = "is_not_empty" CondTextContains = "text_contains" CondTextNotContains = "text_does_not_contain" CondTextStartsWith = "text_starts_with" CondTextEndsWith = "text_ends_with" CondTextIsExactly = "text_is_exactly" CondDateIs = "date_is" CondDateBefore = "date_before" CondDateAfter = "date_after" CondGreaterThan = "greater_than" CondGreaterThanOrEqual = "greater_than_or_equal" CondLessThan = "less_than" CondLessThanOrEqual = "less_than_or_equal" CondIsEqualTo = "is_equal_to" CondIsNotEqualTo = "is_not_equal_to" CondIsBetween = "is_between" CondIsNotBetween = "is_not_between" )
Condition operators for conditional-formatting rules.
Variables ¶
var DateExpressionPattern = regexp.MustCompile(`^(TODAY([+-]\d+)?|\d{4}-\d{2}-\d{2})$`)
Functions ¶
func ResolveDateExpression ¶ added in v0.2.3
func ResolveDatePreset ¶
ResolveDatePreset converts a preset key like "last_30_days" into a map with "start" and "end" date strings. Returns nil if the key is unknown.
func ValidateAll ¶
Types ¶
type AxisEncoding ¶ added in v0.2.1
type AxisEncoding struct {
Field any `yaml:"field" json:"field"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Format string `yaml:"format,omitempty" json:"format,omitempty"`
// BeginAtZero anchors a line/area chart's value axis at 0 (opt-in).
BeginAtZero *bool `yaml:"beginAtZero,omitempty" json:"beginAtZero,omitempty"`
// Markers toggles point markers on line/area charts (default on; false hides).
Markers *bool `yaml:"markers,omitempty" json:"markers,omitempty"`
// Curve is the chart-wide line interpolation: smooth | straight | stepline.
Curve string `yaml:"curve,omitempty" json:"curve,omitempty"`
// Dash is the chart-wide dash pattern every series inherits: dotted | dashed | long-dash (empty = solid).
Dash string `yaml:"dash,omitempty" json:"dash,omitempty"`
}
func (*AxisEncoding) FieldList ¶ added in v0.2.1
func (a *AxisEncoding) FieldList() []string
func (*AxisEncoding) FieldString ¶ added in v0.2.1
func (a *AxisEncoding) FieldString() string
func (*AxisEncoding) MarshalJSON ¶ added in v0.2.1
func (a *AxisEncoding) MarshalJSON() ([]byte, error)
func (*AxisEncoding) MarshalYAML ¶ added in v0.2.1
func (a *AxisEncoding) MarshalYAML() (any, error)
func (*AxisEncoding) UnmarshalJSON ¶ added in v0.2.1
func (a *AxisEncoding) UnmarshalJSON(data []byte) error
func (*AxisEncoding) UnmarshalYAML ¶ added in v0.2.1
func (a *AxisEncoding) UnmarshalYAML(node *yaml.Node) error
type BoundEncoding ¶ added in v0.12.0
type BoundEncoding struct {
Field string // scalar: a single bound column
Map map[string]string // per-series: {series column: bound column}
}
BoundEncoding is a CI bound (yMin/yMax): a single column name (scalar form) or a per-series map {series column: bound column} for multi-line CI bands.
func (BoundEncoding) MarshalJSON ¶ added in v0.12.0
func (b BoundEncoding) MarshalJSON() ([]byte, error)
func (BoundEncoding) MarshalYAML ¶ added in v0.12.0
func (b BoundEncoding) MarshalYAML() (any, error)
func (*BoundEncoding) UnmarshalJSON ¶ added in v0.12.0
func (b *BoundEncoding) UnmarshalJSON(data []byte) error
func (*BoundEncoding) UnmarshalYAML ¶ added in v0.12.0
func (b *BoundEncoding) UnmarshalYAML(node *yaml.Node) error
type ColorEncoding ¶ added in v0.2.2
type ColorEncoding struct {
Field string `yaml:"field" json:"field"`
}
func (*ColorEncoding) FieldString ¶ added in v0.2.2
func (c *ColorEncoding) FieldString() string
type ColorScale ¶ added in v0.13.2
type ColorScale struct {
BackgroundColor []string `yaml:"backgroundColor" json:"backgroundColor"` // at least 2 colors, low → high
Range []float64 `yaml:"range,omitempty" json:"range,omitempty"` // one anchor per color; omit for auto min/max
Unit string `yaml:"unit,omitempty" json:"unit,omitempty"` // absolute (default) | percent | percentile
}
ColorScale is a heatmap's color ramp. It deliberately borrows the table gradient's keys (backgroundColor + range + unit) so an author who has written conditional formatting already knows this, and the frontend resolves both through the same code. Unlike a table gradient, which is scaled per column, this one is scaled across every cell in the grid.
type Dashboard ¶
type Dashboard struct {
Schema string `yaml:"schema,omitempty" json:"schema,omitempty"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Connection string `yaml:"connection,omitempty" json:"connection,omitempty"`
Model string `yaml:"model,omitempty" json:"model,omitempty"`
Models map[string]string `yaml:"models,omitempty" json:"models,omitempty"`
Filters []Filter `yaml:"filters,omitempty" json:"filters,omitempty"`
Queries map[string]Query `yaml:"queries,omitempty" json:"queries,omitempty"`
Rows []Row `yaml:"rows" json:"rows"`
// FilePath is the source file path, not serialized to JSON for API consumers.
FilePath string `yaml:"-" json:"-"`
// FileType indicates the source format: "yaml" or "tsx".
FileType string `yaml:"-" json:"file_type,omitempty"`
// contains filtered or unexported fields
}
Dashboard represents a complete dashboard definition loaded from YAML.
func FindByName ¶
FindByName returns the dashboard with the given name from a slice, or nil.
func LoadDir ¶
LoadDir discovers and loads all dashboard files from the project's dashboards directory.
func LoadOneByName ¶
LoadOneByName finds a dashboard by name using a two-pass approach: first a cheap metadata scan (no query execution) to find the file path, then a full load of just that one file. Returns nil, nil if not found.
func LoadTSXFile ¶
LoadTSXFile loads a single .dashboard.tsx file by transpiling it with esbuild and executing it with goja to produce a Dashboard struct.
func (*Dashboard) DateRangeFilterName ¶
DateRangeFilterName returns the name of the first date-range filter, or "".
func (*Dashboard) DefaultFilters ¶
DefaultFilters returns a map of filter names to their default values. For date-range filters, string defaults like "last_30_days" are resolved to {start, end} maps so that query templating works correctly.
func (*Dashboard) ResolveSemanticModel ¶
func (*Dashboard) ResolveWidgetSemanticJob ¶
func (d *Dashboard) ResolveWidgetSemanticJob(w *Widget) (*SemanticJob, bool, error)
type Filter ¶
type Filter struct {
Name string `yaml:"name" json:"name"`
Type string `yaml:"type" json:"type"`
Multiple bool `yaml:"multiple,omitempty" json:"multiple,omitempty"`
Default any `yaml:"default,omitempty" json:"default,omitempty"`
Options *FilterOptions `yaml:"options,omitempty" json:"options,omitempty"`
}
type FilterOptions ¶
type FilterOptions struct {
Values []string `yaml:"values,omitempty" json:"values,omitempty"`
Query string `yaml:"query,omitempty" json:"query,omitempty"`
Connection string `yaml:"connection,omitempty" json:"connection,omitempty"`
Presets []string `yaml:"presets,omitempty" json:"presets,omitempty"` // date-range: which presets to show
}
type FormatLayer ¶ added in v0.8.0
type FormatLayer struct {
If string `yaml:"if,omitempty" json:"if,omitempty"`
Value any `yaml:"value,omitempty" json:"value,omitempty"` // scalar, [low, high], or {column: X}
BackgroundColor any `yaml:"backgroundColor,omitempty" json:"backgroundColor,omitempty"` // string (flat/single) | []string (gradient)
Range []float64 `yaml:"range,omitempty" json:"range,omitempty"` // gradient anchors, paired with Unit
Unit string `yaml:"unit,omitempty" json:"unit,omitempty"` // absolute | percent | percentile
TextColor string `yaml:"textColor,omitempty" json:"textColor,omitempty"`
Bold bool `yaml:"bold,omitempty" json:"bold,omitempty"`
Italic bool `yaml:"italic,omitempty" json:"italic,omitempty"`
Underline bool `yaml:"underline,omitempty" json:"underline,omitempty"`
Strikethrough bool `yaml:"strikethrough,omitempty" json:"strikethrough,omitempty"`
ScaleBy string `yaml:"scaleBy,omitempty" json:"scaleBy,omitempty"` // pivot gradient domain: row | column (default whole grid)
}
FormatLayer is one entry in a column's ordered `format` list; the first layer that matches a cell wins. A layer with `If` set is a condition (applies to matching cells). A layer without `If` always applies — a gradient (array backgroundColor, optional range/unit) or a flat fill (string backgroundColor); place it last as the fallback base.
type NoQueryError ¶
type NoQueryError struct {
Widget string
}
func (*NoQueryError) Error ¶
func (e *NoQueryError) Error() string
type PivotConfig ¶ added in v0.16.0
type PivotConfig struct {
Rows []PivotField `yaml:"rows,omitempty" json:"rows,omitempty"`
Columns []PivotField `yaml:"columns,omitempty" json:"columns,omitempty"`
Values []PivotValue `yaml:"values,omitempty" json:"values,omitempty"`
}
PivotConfig reshapes a pivot_table widget's flat result into a pivot table.
type PivotField ¶ added in v0.16.0
type PivotField struct {
Field string `yaml:"field" json:"field"`
Order string `yaml:"order,omitempty" json:"order,omitempty"` // asc | desc (default asc)
ShowTotals bool `yaml:"showTotals,omitempty" json:"showTotals,omitempty"`
}
PivotField is one nested group-by level (rows or columns axis).
type PivotValue ¶ added in v0.16.0
type PivotValue struct {
Field string `yaml:"field" json:"field"`
Summarize string `yaml:"summarize,omitempty" json:"summarize,omitempty"` // default sum; see validPivotAggregations
Label string `yaml:"label,omitempty" json:"label,omitempty"`
Format []FormatLayer `yaml:"format,omitempty" json:"format,omitempty"`
}
PivotValue is an aggregated measure. Format applies the same conditional-format layers as a table column, but scaled over this value's own leaf cells.
type ProjectPaths ¶
func ResolveProjectPaths ¶
func ResolveProjectPaths(dir string) ProjectPaths
func ResolveProjectPathsForFile ¶
func ResolveProjectPathsForFile(path string) ProjectPaths
type Query ¶
type Query struct {
SQL string `yaml:"sql,omitempty" json:"sql,omitempty"`
Connection string `yaml:"connection,omitempty" json:"connection,omitempty"`
Model string `yaml:"model,omitempty" json:"model,omitempty"`
Dimensions []SemanticDimensionRef `yaml:"dimensions,omitempty" json:"dimensions,omitempty"`
Metrics []string `yaml:"metrics,omitempty" json:"metrics,omitempty"`
Filters []SemanticQueryFilter `yaml:"filters,omitempty" json:"filters,omitempty"`
Segments []string `yaml:"segments,omitempty" json:"segments,omitempty"`
Sort []SemanticSort `yaml:"sort,omitempty" json:"sort,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
}
Query represents a named query definition.
func (*Query) IsSemantic ¶
type QueryNotFoundError ¶
func (*QueryNotFoundError) Error ¶
func (e *QueryNotFoundError) Error() string
type RefBand ¶ added in v0.12.0
type RefBand struct {
Axis string `yaml:"axis" json:"axis"` // "x" | "y"
From float64 `yaml:"from" json:"from"`
To float64 `yaml:"to" json:"to"`
Label string `yaml:"label,omitempty" json:"label,omitempty"`
Color string `yaml:"color,omitempty" json:"color,omitempty"`
}
RefBand is a shaded reference band spanning from→to on a chart's x or y axis.
type RefLine ¶ added in v0.12.0
type RefLine struct {
Axis string `yaml:"axis" json:"axis"` // "x" | "y"
Value float64 `yaml:"value" json:"value"`
Label string `yaml:"label,omitempty" json:"label,omitempty"`
Color string `yaml:"color,omitempty" json:"color,omitempty"`
}
RefLine is a reference guide line on a chart's x or y axis.
type SemanticDimensionRef ¶
type SemanticJob ¶
type SemanticJob struct {
Model *sem.Model
ModelName string
Connection string
Query sem.Query
// Models is the full set of semantic models in the project, keyed by name.
// It is passed to the engine so queries can reference dimensions on joined
// models (e.g. "customers.country").
Models map[string]*sem.Model
}
type SemanticQueryFilter ¶
type SemanticQueryFilter struct {
Dimension string `yaml:"dimension,omitempty" json:"dimension,omitempty"`
Operator string `yaml:"operator,omitempty" json:"operator,omitempty"`
Value any `yaml:"value,omitempty" json:"value,omitempty"`
Expression string `yaml:"expression,omitempty" json:"expression,omitempty"`
}
type SemanticSort ¶
type SeriesStyle ¶ added in v0.12.1
type SeriesStyle struct {
Color string `yaml:"color,omitempty" json:"color,omitempty"` // #hex; unset uses the palette
Curve string `yaml:"curve,omitempty" json:"curve,omitempty"` // smooth | straight | stepline (falls back to y.curve)
Dash string `yaml:"dash,omitempty" json:"dash,omitempty"` // solid | dotted | dashed | long-dash (falls back to y.dash)
}
SeriesStyle is a per-series style override, grouped under Widget.Series and keyed by the y-column the style applies to.
type SliceStyle ¶ added in v0.15.0
type SliceStyle struct {
Color string `yaml:"color,omitempty" json:"color,omitempty"` // #hex; unset uses the palette
Label string `yaml:"label,omitempty" json:"label,omitempty"` // display name; unset uses the raw data label
}
SliceStyle is a per-slice style override for label/value charts, grouped under Widget.Slices and keyed by the slice's displayed label.
type TableColumn ¶
type TableColumn struct {
Name string `yaml:"name" json:"name"`
Label string `yaml:"label,omitempty" json:"label,omitempty"`
Number string `yaml:"number,omitempty" json:"number,omitempty"` // value display: currency | number | d3-format spec
Like string `yaml:"like,omitempty" json:"like,omitempty"` // mirror another column's coloring + per-row value
Hidden bool `yaml:"hidden,omitempty" json:"hidden,omitempty"` // keep the column in the result (for cross-column rules / like) but don't render it
Align string `yaml:"align,omitempty" json:"align,omitempty"` // text alignment override: left | center | right (applies to the header and body cells)
Format []FormatLayer `yaml:"format,omitempty" json:"format,omitempty"` // ordered conditional-format style layers; first match wins
}
func (*TableColumn) UnmarshalYAML ¶ added in v0.9.0
func (c *TableColumn) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML makes a column's `format` polymorphic for backward compatibility. Originally `format` was a scalar value-display shorthand (`format: currency`); that role is now `number`, and `format` is an ordered list of style layers. So a scalar `format` is read as the legacy value format and folded into Number (unless Number is set explicitly); a list is decoded as the style layers. Value display (`number`, or a scalar `format`) and coloring (`format: [...]`) coexist.
type ValidationError ¶
ValidationError holds all validation issues for a dashboard.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationSetError ¶
type ValidationSetError struct {
Errors []error
}
func (*ValidationSetError) Error ¶
func (e *ValidationSetError) Error() string
type ValueEncoding ¶ added in v0.2.1
type ValueEncoding struct {
Field string `yaml:"field" json:"field"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Format string `yaml:"format,omitempty" json:"format,omitempty"`
}
func (*ValueEncoding) FieldString ¶ added in v0.2.1
func (v *ValueEncoding) FieldString() string
func (*ValueEncoding) MarshalJSON ¶ added in v0.2.1
func (v *ValueEncoding) MarshalJSON() ([]byte, error)
func (*ValueEncoding) MarshalYAML ¶ added in v0.2.1
func (v *ValueEncoding) MarshalYAML() (any, error)
func (*ValueEncoding) UnmarshalJSON ¶ added in v0.2.1
func (v *ValueEncoding) UnmarshalJSON(data []byte) error
func (*ValueEncoding) UnmarshalYAML ¶ added in v0.2.1
func (v *ValueEncoding) UnmarshalYAML(node *yaml.Node) error
type Widget ¶
type Widget struct {
ID string `yaml:"id,omitempty" json:"id,omitempty"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Type string `yaml:"type" json:"type"`
Col int `yaml:"col,omitempty" json:"col,omitempty"`
// Query source (pick one)
QueryRef string `yaml:"query,omitempty" json:"query,omitempty"` // reference to queries map key
SQL string `yaml:"sql,omitempty" json:"sql,omitempty"`
MetricRef string `yaml:"metric,omitempty" json:"metric,omitempty"` // reference to metrics map key
Model string `yaml:"model,omitempty" json:"model,omitempty"`
// Inline static data — an alternative to a query source. A widget with
// Data renders without a connection or SQL; encoding fields (x/y/value/
// label/columns) reference the column names in Data. Used for hardcoded
// or sample dashboards, e.g. before a warehouse is connected.
Data *WidgetData `yaml:"data,omitempty" json:"data,omitempty"`
// Connection override for inline queries
Connection string `yaml:"connection,omitempty" json:"connection,omitempty"`
// Declarative chart fields (use with source + metrics)
Dimension string `yaml:"dimension,omitempty" json:"dimension,omitempty"` // GROUP BY column
Granularity string `yaml:"granularity,omitempty" json:"granularity,omitempty"`
Dimensions []SemanticDimensionRef `yaml:"dimensions,omitempty" json:"dimensions,omitempty"`
MetricRefs []string `yaml:"metrics,omitempty" json:"metrics,omitempty"` // metric names to aggregate
Filters []SemanticQueryFilter `yaml:"filters,omitempty" json:"filters,omitempty"`
Segments []string `yaml:"segments,omitempty" json:"segments,omitempty"`
Sort []SemanticSort `yaml:"sort,omitempty" json:"sort,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"` // LIMIT for dimensional queries
// Chart fields
Chart string `yaml:"chart,omitempty" json:"chart,omitempty"` // built-in chart type, or vega-lite
Spec map[string]any `yaml:"spec,omitempty" json:"spec,omitempty"` // vega-lite: visualization spec; DAC query data is injected as the named "dac" dataset
X *AxisEncoding `yaml:"x,omitempty" json:"x,omitempty"`
Y *AxisEncoding `yaml:"y,omitempty" json:"y,omitempty"`
// Y2 is an optional second value axis on the right (line/area/bar/combo): a
// y-column plots against it when listed in y2.field, all others stay on y.
Y2 *AxisEncoding `yaml:"y2,omitempty" json:"y2,omitempty"`
Label string `yaml:"label,omitempty" json:"label,omitempty"` // for pie/funnel/treemap
Value *ValueEncoding `yaml:"value,omitempty" json:"value,omitempty"` // metric: the value; pie/funnel/heatmap/calendar/treemap/gauge: value column
Color *ColorEncoding `yaml:"color,omitempty" json:"color,omitempty"`
Stacked bool `yaml:"stacked,omitempty" json:"stacked,omitempty"`
Normalized bool `yaml:"normalized,omitempty" json:"normalized,omitempty"`
Horizontal *bool `yaml:"horizontal,omitempty" json:"horizontal,omitempty"` // bar/funnel: horizontal layout; forest: defaults horizontal, set false for a vertical dot-and-whisker. Pointer so an explicit false survives JSON marshaling.
Size string `yaml:"size,omitempty" json:"size,omitempty"`
Source string `yaml:"source,omitempty" json:"source,omitempty"` // sankey: source column
Target string `yaml:"target,omitempty" json:"target,omitempty"` // sankey: target column, gauge: target (max) column
Bins int `yaml:"bins,omitempty" json:"bins,omitempty"` // histogram: number of bins
ShowValues bool `yaml:"showValues,omitempty" json:"showValues,omitempty"` // heatmap: print each cell's value inside the cell
ColorScale *ColorScale `yaml:"colorScale,omitempty" json:"colorScale,omitempty"` // heatmap: custom color ramp, same keys as a table gradient
Lines []string `yaml:"lines,omitempty" json:"lines,omitempty"` // combo: which y series render as lines
// Series holds per-series line style overrides keyed by y-column: {column: {color, curve, dash}}.
Series map[string]SeriesStyle `yaml:"series,omitempty" json:"series,omitempty"`
// Slices holds per-slice style overrides for label/value charts (pie/treemap/funnel), keyed by slice label: {label: {color}}.
Slices map[string]SliceStyle `yaml:"slices,omitempty" json:"slices,omitempty"`
YMin *BoundEncoding `yaml:"yMin,omitempty" json:"yMin,omitempty"` // xmr: min control limit column; line/bar/forest: CI lower bound (column or per-series map)
YMax *BoundEncoding `yaml:"yMax,omitempty" json:"yMax,omitempty"` // xmr: max control limit column; line/bar/forest: CI upper bound (column or per-series map)
Open string `yaml:"open,omitempty" json:"open,omitempty"` // candlestick: open price column
High string `yaml:"high,omitempty" json:"high,omitempty"` // candlestick: high price column
Low string `yaml:"low,omitempty" json:"low,omitempty"` // candlestick: low price column
Close string `yaml:"close,omitempty" json:"close,omitempty"` // candlestick: close price column
RefLines []RefLine `yaml:"refLines,omitempty" json:"refLines,omitempty"` // reference guide lines (axis + value + optional label)
RefBands []RefBand `yaml:"refBands,omitempty" json:"refBands,omitempty"` // shaded reference bands (axis + from/to + optional label)
// Table fields
Columns []TableColumn `yaml:"columns,omitempty" json:"columns,omitempty"`
// Pivot turns a table's flat result set into a spreadsheet-style pivot,
// computed and rendered client-side. Table widgets only — see PivotConfig.
Pivot *PivotConfig `yaml:"pivot,omitempty" json:"pivot,omitempty"`
// Text fields
Content string `yaml:"content,omitempty" json:"content,omitempty"`
// Image fields
Src string `yaml:"src,omitempty" json:"src,omitempty"`
Alt string `yaml:"alt,omitempty" json:"alt,omitempty"`
}
Widget represents a single dashboard widget. Query resolution priority: query (named ref) > sql (inline) > data (static).
func (*Widget) ColorField ¶ added in v0.2.2
func (*Widget) HasInlineData ¶ added in v0.4.0
HasInlineData reports whether the widget carries static inline data.
func (*Widget) IsSemantic ¶
func (*Widget) ResolvedQuery ¶
ResolvedQuery returns the SQL and connection for this widget, resolving named query references. Widgets with MetricRef are handled separately and should not call this method.
func (*Widget) ValueField ¶ added in v0.2.1
type WidgetData ¶ added in v0.4.0
type WidgetData struct {
Columns []string `yaml:"columns" json:"columns"`
Rows [][]any `yaml:"rows" json:"rows"`
}
WidgetData holds inline result data for a widget so it can render without a connection. Columns are column names; each entry in Rows is positional and must have one value per column. This mirrors the {columns, rows} shape the frontend uses for executed query results.