Angular Embedded AnalyticsStudio Overview

This section provides key information for configuring and interacting with Studio.

Studio Properties Copy Link

Studio is configured via Inputs on the ag-studio component. Properties consist of simple types, arrays, complex objects and callback functions.

<ag-studio
    // Set boolean properties
    enableRtl
    // Bind property / callback to component
    [data]="myData"
    // Callback
    [getLocaleText]="getLocaleText"
    // Event handlers
    (stateUpdated)="onStateUpdated($event)"
    />

Updating Studio Properties Copy Link

It is a common requirement to update a Studio property after Studio has been created. For example, you may want to change mode via an application toggle.

Simply update the bound property and Studio will respond to the new value. In this example the mode will switch to view.

<ag-studio [mode]="mode" />

updateMode() {
    this.mode = 'view';
}

Properties can also be updated by calling either api.setProperty or api.updateProperties.

// update the mode
api.setProperty('mode', 'view');

Initial Studio Properties Copy Link

A small number of Studio properties do not support updating their value. Their value is only read during the initial setup of Studio. These options are marked as Initial on the Properties Reference. For these properties Studio must be destroyed and re-created for the new value to take effect.

Not all Studio Properties support updates. These are marked as Initial.

For a full list of properties, see Properties Reference.

Studio Events Copy Link

As a user interacts with Studio, events will be fired to enable your application to respond to specific actions.

To listen to an event pass your event handler to the relevant Output property on the ag-studio component.

onStateUpdated(event: AgStudioStateUpdatedEvent) {
  console.log("State was updated")
}

<ag-studio (stateUpdated)="onStateUpdated($event)">

TypeScript users can take advantage of the events' interfaces. Construct the interface name by prefixing the event name with AgStudio and suffixing with Event. For example, the stateUpdated event uses the interface AgStudioStateUpdatedEvent.

For a full list of events, see Studio Events.

Studio API Copy Link

The API can be accessed from the AgStudio component via a @ViewChild decorator from within your component. This will be defined after ngAfterViewInit has run.

// Add a template reference to Studio
<ag-studio #myStudio  />

// Select Studio via template reference
@ViewChild('myStudio') studio!: AgStudio;

// Access the API off Studio
onClick() { this.studio.api.getState() }

The api is also provided on the params for all Studio events and callbacks. The first event fired is the apiReady event and that can be used to store a reference to the API.

<ag-studio (apiReady)="onApiReady($event)" />

private api!: agStudioApi;
onApiReady = (event: AgStudioApiReadyEvent) => {
    // Store the API for later use
    this.api = event.api;
}

For a full list of API methods, see Studio API.

Studio State Copy Link

As a user interacts with Studio they may change state such as widget layout, formatting, filtering, etc. This state is independent of the configuration, and to provide save and restore capabilities Studio enables applications to save / restore this state.

For a full list of the state properties, see Studio State.

Studio Lifecycle Copy Link

An application may need to perform actions when Studio is first initialised, or about to be destroyed.

For full details about how to interact with Studio at these key moments see: Studio Lifecycle.

Studio Errors Copy Link

When errors occur in state or data validation, an error event will be emitted.

<ag-studio
    [onErrorRaised]="onErrorRaised"
    /* other studio properties ... */ />

this.onErrorRaised = (params) => {
    // handle error (e.g. prompt user to load a different report)
};
errorRaisedCopy Link
AgStudioErrorRaisedEvent
An error has occurred within Studio.