grafana/grafana
@grafana/data
The foundational data-handling package. Defines the types and helpers that every other Grafana package and every plugin builds on top of. Source under packages/grafana-data/.
Core types
DataFrame and Field
A DataFrame is Grafana's columnar dataframe — the universal in-memory representation of query results. Every datasource returns DataFrame[]. Defined in packages/grafana-data/src/types/dataFrame.ts.
interface DataFrame {
name?: string;
refId?: string;
meta?: QueryResultMeta;
fields: Field[];
length: number;
}
interface Field<T = any> {
name: string;
type: FieldType; // 'time' | 'number' | 'string' | 'boolean' | ...
config: FieldConfig;
values: T[]; // or Vector<T>
state?: FieldState;
}Helpers like toDataFrame, getFieldDisplayName, applyFieldOverrides make it straightforward to construct, transform, and pretty-print frames.
LoadingState and query lifecycle
The query execution result type PanelData carries a LoadingState (NotStarted | Loading | Streaming | Done | Error) along with series: DataFrame[], error?, request?. Used by panels and Explore to know what to render.
TimeRange and TimeZone
Time math helpers — dateMath.parse('now-1h'), range comparison, time zone resolution — are in packages/grafana-data/src/datetime/.
Themes
createTheme(name) produces a GrafanaTheme2 (packages/grafana-data/src/themes/) with token shapes for colors, typography, spacing, shape, transitions, breakpoints. Both @grafana/ui and apps consume themes via useTheme2() / useStyles2(getStyles).
Themes are extensible — apps and plugins can extend tokens and even register custom palettes. Generated SCSS variables for legacy code paths live alongside via themes:generate.
Value formatters
packages/grafana-data/src/valueFormats/ catalogues every unit available in panel field-config (bytes, percent, seconds, currencies, locales). The categories.ts file is one of the largest in the package — it's the registry of every formatter, indexed by family.
Field configuration and overrides
Per-field display configuration (units, decimals, color thresholds, mappings) plus the override system (regex/glob/byName matchers) lives in packages/grafana-data/src/field/. applyFieldOverrides is what panels call to resolve defaultsAndOverrides → effectiveConfig.
Transformations
The data transformation pipeline is in packages/grafana-data/src/transformations/. Each transformer (rename, filter, group by, calculate field, …) implements a stable interface; the registry lets the dashboard UI present them in the panel-edit "Transform" tab.
Plugin metadata
Types like PanelPlugin, DataSourcePlugin, AppPlugin, PluginMeta, and the various PluginsExtensionRegistry shapes come from @grafana/data. External plugin packages depend on these for their public surface.
Selectors and registries
registryFactory (packages/grafana-data/src/utils/Registry.ts) is the small generic registry used by units, transformers, and themes.
What does NOT live here
- React components — those go in
@grafana/ui. - Network helpers —
getBackendSrv()is in@grafana/runtime. - Imperative singletons —
getDataSourceSrv()is in@grafana/runtime.
Key source files
| File | Purpose |
|---|---|
packages/grafana-data/src/types/dataFrame.ts |
DataFrame & Field types |
packages/grafana-data/src/types/featureToggles.gen.ts |
Generated feature-toggles type |
packages/grafana-data/src/themes/ |
Theme tokens |
packages/grafana-data/src/valueFormats/categories.ts |
Unit registry |
packages/grafana-data/src/transformations/ |
Transformation pipeline |
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.