AG Studio: Build dashboards using native components in web apps. Join us for a webinar on 28th July at 2pm UTC+1 Register

React Embedded AnalyticsSharing & Caching Data

A Data Engine loads, processes, and caches data for Studio widgets. Studio creates one automatically when you pass data sources via the data property, but you can create the engine yourself to share it across instances, or replace it entirely with a custom backend.

Built-in Engine Copy Link

When you pass data sources directly to Studio, it creates a built-in Data Engine behind the scenes. Creating the engine externally with createDataEngine(data) gives you two benefits:

  • Sharing - multiple Studio instances can point at the same engine, so they share a single copy of the data.
  • Caching across lifecycles - the engine survives when Studio is destroyed and recreated, so data doesn't need to be re-fetched or reprocessed on remount.
const dataEngine = createDataEngine({
    sources: [{
        id: 'medals',
        data: [
            {
                year: 2000,
                sport: 'Swimming',
                country: 'United States',
                // ... other fields
            },
            // ... other rows
        ],
    }],
});
const data = useMemo(() => { 
	return dataEngine;
}, []);

<AgStudio data={data} />

See Sync Data and Async Data for the full range of data loading patterns.

createDataEngine(data) accepts a data object of type AgDataSourcesDefinition.

sourcesCopy Link
AgDataSource<TRegistry>[]
One or more data sources.
relationshipsCopy Link
AgRelationDefinition[]
When using multiple related tables, this describes the fields that link the tables together.
expressionsCopy Link
AgExpressionFieldDefinition<TRegistry>[]
Expression field definitions for calculated columns.
formatsCopy Link
TRegistry['formats']
Overrides to existing formats, or additional custom formats.
descriptionCopy Link
string
AI-facing overview of the entire dataset: what it contains, what it's for, domain quirks.
calendarsCopy Link
AgCalendar[]
Named time dimensions (calendars) that supply date fragments and a continuous date spine.
bucketsCopy Link
TRegistry['buckets']
Additional date-fragment bucket definitions to register alongside the built-in set (year, quarter, month, week, day, monthOfYear, dayOfWeek, …). Use this to add project-specific groupings such as weekend, dayOfMonth, or hour that the built-in registry does not include. Provide via createBuckets so type-level registry inference works correctly.

Custom Engines Copy Link

For larger datasets or when you want to delegate query execution to a backend you already own, see the Server-Side Data guide.